Logo
Published on

Git FAQ: How to Delete a Branch Both Locally and Remotely

Authors
  • avatar
    Name
    Mike Tsamis
    Twitter

Deleting a Local Branch

To delete the local branch use one of the following commands:

git branch -d <branch_name>
git branch -D <branch_name>

What is the difference? “-d” is short for “--delete” which will only delete a branch that has already been merged in its upstream branch. “-D” is short for “—delete --force” which will delete the branch regardless of whether or not it is merged into an upstream branch.

Deleting a Remote Branch

To delete a remote branch, run this command:

git push <remote_name> --delete <branch_name>

Related Articles