How do I delete a branch in Git?

Deleting a branch locally and remotely

In a typical Git repository you may have a couple of permanent branches, such as master and development that are constantly worked on, but also a number of branches that are temporary, for things like bug fixes, new features, or versions of your project.

Lots of developers choose to delete their branches once they've finished working on them to keep their repository tidy.

There are two steps to deleting a branch from a repository completely:

  1. Delete the branch locally
  2. Delete the branch on the remote

Deleting a local branch

You can use git branch (with no arguments) for a list of all the local branches you have "checked out" on your computer.

* master

Run the following command to delete a specific branch locally:

$ git branch -d your-branch-name

Deleting a remote branch

If you've previously pushed the branch, it'll still exist on the remote repository. You can see this by running git branch -r to get a list of all the remote branches.


In order to delete the branch remotely, you'll need to "push" the deletion by running the following command:

git push --delete origin your-branch-name

After that, you'll no longer have a copy of that branch stored locally on your computer, or in your remote repository.

Proudly powered by Katapult. Running on 100% renewable energy.