Tag Archives: git

How to delete a branch in git

Git Logo
Image by Jason Long CC BY 3.0

Git encourages branching but sometimes you need to do a clean up and delete merged or orphaned branches from your local and remote repositories. Here is the procedure from the command line.

To delete a branch locally:

You may get an error like this one if the branch has not been merged yet:

This is a good reminder in case you are deleting something you should not be deleting.

To delete a branch remotely (e.g. on a GitHub repository):