• 0

How to delete a branch on a remote repository

I often found myself working on local feature branches that I pushed to remotes just so that there is always a backup of my source code in another location. Such feature branches that nobody else has branched becomes obsolete after its changes have been merged. While github lets you delete branches from their website, if you are not using github, or maybe just using a remote computer to collaborate, you will have to delete those feature branches from the remote yourself.

While deleting a local branch is not uncommon, deleting a remote branch is something that you should probably not be doing if someone else has branches based upon the branch that you wish to delete. Therefore use these commands with caution.

There are 2 simple ways in which you can delete a git branch on a remote repository.

git push --delete remoteName branchname


git push remoteName :branchName