I want to delete a branch both locally and remotely.
$ git branch -d
Many of the other answers will lead to errors/warnings. This approach is relatively fool proof although you may still need git branch -D branch_to_delete
if it's not fully merged into some_other_branch
, for example.
git checkout some_other_branch
git push origin :branch_to_delete
git branch -d branch_to_delete
Remote pruning isn't needed if you deleted the remote branch. It's only used to get the most up-to-date remotes available on a repository you're tracking. I've observed git fetch
will add remotes, not remove them. Here's an example of when git remote prune origin
will actually do something:
User A does the steps above. User B would run the following commands to see the most up-to-date remote branches:
git fetch
git remote prune origin
git branch -r