I wrongly pushed my code using Xcode toolbar into my repository on github. now, I want to delete all files in my master branch, but not the repository. Then I want to pull my code into repository this time instead of pushing. Does any one know how to delete all contents of master branch?
In git, you can't delete the content of a branch. All you can do is to push a commit that removes all your files. If you want to start over from a clean repository, you have to delete the current one a create a new one with the same name for example.
The web interface on GitHub.com allows you to do basic editing tasks. You can delete a specific file after opening its detail view and then clicking on the little trash can icon: However, you cannot delete multiple files in one go nor can you delete folders in the GitHub web interface.
If you commit sensitive data, such as a password or SSH key into a Git repository, you can remove it from the history. To entirely remove unwanted files from a repository's history you can use either the git filter-repo tool or the BFG Repo-Cleaner open source tool.
In git, you can't delete the content of a branch. All you can do is to push a commit that removes all your files.
If you want to start over from a clean repository, you have to delete the current one a create a new one with the same name for example.
Just to support quentin's answer, adding the git commands:
Keep a backup of the local repository folder and remove all its contents.
Add these changes to commit
$ git add *
$ git commit "Remove everything"
$ git push -f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With