How to Delete a Remote Git Branch?

Find out how to delete a remote git branch

The command to delete a remote git branch has the following syntax:

# git 1.7+
git push <remote_name> --delete <branch_name>

# or the shorter version
git push <remote_name> -d <branch_name>

For git 1.5+, the syntax slightly differs:

# git 1.5+
git push <remote_name> :<branch_name>

For example, if "origin" is the remote name, and "foo" is the branch you wish to delete, then you would use the following command:

# git 1.7+
git push origin --delete foo

# or the shorter version
git push origin -d foo

And in git 1.5, you would, for example, use the following command:

# git 1.5+
git push origin :foo

Please note that these commands do not delete the local branch. Deleting a local branch is done using an entirely different command.


Hope you found this post useful. It was published . Please show your love and support by sharing this post.