How To Completely Delete Git Branch

How To Completely Delete Git Branch

Explains the commands and steps required to completely delete a git branch both locally and the remote server.

February 27, 2019

This post list the commands required to delete a git branch both locally and on the remote server.

Delete Branch Locally

The git command branch -d can be used to delete a branch locally.

# Delete local branch
git branch -d <branch name>

# Example - Delete the local branch dev
git branch -d dev

Delete Branch on Remote Server

The git command push can be used to delete a branch on the remote server as shown below for a remote server named origin.

# Delete remote branch

git push origin :<branch name>
# OR
git push --delete origin <branch name>


# Example - Delete the remote branch dev
git push origin :dev
# OR
git push --delete origin dev

Write a Comment
Click the captcha image to get new code.
Discussion Forum by DISQUS