Git: Delete Local and Remote Branch

Learn how to delete local and remote branches in Git.

Git: Delete Local and Remote Branch

How to delete a local branch in Git?

To delete a local branch without unmerged commits, use this command:

git branch -d branch-name

To delete a local git branch that contains unmerged commits, use this command:

git branch -D branch-name

The -D tells git to force delete the branch.

How to delete a remote branch in Git?

To delete the remote/upstream git branch, you need to use the git push command:

git push remote-name --delete branch-name