Select Page

Delete Git branch locally can be done by providing -d parameter to git branch command. In some cases, git can complain that a branch is not fully merged, and it will refuse to delete it, in that case, you can use -D parameter (capital D), it will force Git to remove it.

# remove git branch locally git branch -d branch-name # force git to delete branch locally when it refuse to delete it using previous command git branch -D branch-name

How to delete git branch from a remote repository

In order to remove the git branch on a remote git repository, for example, Bitbucket or Github, you need to use the following command

# remove git branch on remote server, the branch is not removed from local machine in this case git push origin --delete branch-name