What do you think? Discuss, post comments, or ask questions at the end of this article [More about me]

Skip to end of metadata
Go to start of metadata

Deleting local branches

You can delete a local branch by

git branch -d <localBranchName>

This one has come in handy a few times: if you want to delete all local branches (maybe to clean up) except master, you can do

git branch | grep -v "master" | xargs git branch -D 

Note: assumes master branch is called "master".

Deleting remote branches

Deleting a local branch is pretty straight forward - but what about deleting its remote branch?

To do this simply execute the following from git bash:

git push <remote> --delete <branch>

Where <remote> is the remote repo (e.g. origin etc.) and <branch> is the name of the remote branch to delete.