Delete local and remote git branches

Just a quick one for reference..

Deleting one or more local branches is trivial:
git branch --delete branch branch2

However if you want to delete regardless of the merge state:
git branch -D branch branch2

To delete a remote branch you need to push the delete:
git push remote --delete branch

The –delete option is newish, so if your git is old you can use the original syntax:
git push remote :branch

That’s all.

Leave a Reply

Your email address will not be published. Required fields are marked *