Delete a local branch

A local branch is a branch which is the one inside the computer.

To delete a local branch, execute following git command. Replace the branch_name with the one that you want to remove in your local computer.


git branch -d branch_name

To force delete a local branch, replace -d with -D, a capital d in the same command as above.


git branch -D local_branch_name

Delete a remote branch

A remote branch is a branch which resides in a remote repository, such as Bitbucket, GitLab, GitHub and so on.

To delete a local branch, execute following git command. Replace the origin with the one that you want to remove in your local computer.


git push origin --delete branch_name

In most cases, a remote_name is origin. To see a list of remote branch. Use the following command.

git branch -r

Last modified: August 14, 2018

Author