How to delete a branch on a remote repository

I often found myself work­ing on local fea­ture branches that I pushed to remotes just so that there is always a backup of my source code in another loca­tion. Such fea­ture branches that nobody else has branched becomes obso­lete after its changes have been merged. While github lets you delete branches from their web­site, if you are not using github, or maybe just using a remote com­puter to col­lab­o­rate, you will have to delete those fea­ture branches from the remote yourself.

While delet­ing a local branch is not uncom­mon, delet­ing a remote branch is some­thing that you should prob­a­bly not be doing if some­one else has branches based upon the branch that you wish to delete. There­fore use these com­mands with caution.

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

git push --delete remoteName branchname

OR

git push remoteName :branchName

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *