Delete Git branch locally and remotely
To remove a local branch
git branch -d <branch-name>
Use -D
instead to force deleting the branch without checking merged status.
Effectively, -D
means --delete --force
and -d
means --delete
To remove a remote branch
git push <remote-name> -d <remote-branch-name>
shorter syntax
git push <remote-name> :<remote-branch-name>
Tips
After the local or remote branch has been deleted, other machines will likely still have "obsolete tracking branches" (to see them use git branch -a
).
To get rid of these do
git fetch --all --prune