Git: remove a tag or branch on the remote server

Here you can find the commands to remove a tag or a branch from a remote Git repository.

I find difficult to remember the Git commands to remove a remote tag or a branch on the remote server.

Scott Chacon actually explain it well in his ProGit book.

A way to remember this command is by recalling the git push [remotename] [localbranch]:[remotebranch] If you leave off the [localbranch] portion, then you’re basically saying, "Take nothing on my side and make it be [remotebranch]".

Then to remove we actually push an empty branch/tag to the branch on remote.

So let say our remotename is origin and remotebranch is serverfix, then to remove a remote branch:

$ git push origin :serverfix

and to remove a tag on the remote server:

$ git push origin :refs/tags/serverfix