How To Completely Delete Git Branch

GIT
By bhagwatchouhan
How To Completely Delete Git Branch

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

 

share on :

Profile picture for user bhagwatchouhan
bhagwatchouhan