I'm pretty new to using git, and I use it to contribute to the AOKP Android ROM. I've successfully created a few branches, modified the code, and uploaded the commits that have gotten merged on the remote end. But in my local repository, those branches are still showing up (even though they show up as having no changes). The problem is that when I created those branches, I did so right from the subfolder that needed to be modified, so I don't have any "higher" branches to go to. And because of that, I can't delete those branches -- git tels me error: Cannot delete the branch 'MyMods' which you are currently on.
So what can I do to get rid of those branches?
The command to delete a local git branch can take one of two forms: git branch –delete old-branch. git branch -d old-branch.
Deleting a branch LOCALLY Delete a branch with git branch -d <branch> . The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet. The branch is now deleted locally.
What Happens If I Delete a Git Branch? When you delete a branch in Git, you don't delete the commits themselves. That's right: The commits are still there, and you might be able to recover them.
Checkout a different branch first, before deleting it:
git checkout master git branch -d MyMods
Also, branches have nothing to do with folders. Git always tracks the whole repository at once, with all its folders and files. A branch is nothing else than a pointer to a single commit, or snapshot, in the history of the repository.
Yes just checkout another branch(maybe master) and then:
git checkout master git branch -d thebran
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