How to delete Git branch both locally and remotely

Delete Git branch locally can be done providing -d parameter to git branch command. In some cases git can complain than 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 remote repository

In order to remove git branch on 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



Comments

Social media

Search

Latest Tweets