How To Delete A Remote Git Tag

Sometimes you push a bad tag and need to remove it. This is how.
November 1, 2017
git

Occasionally I tag something and push it, only to realize that I did it wrong. My tags are tied to Gitlab and Github releases, and some, such as hugo and syncthing are picked up by Docker Hub for automatic builds.

In some cases I’ll just increment the tag and move on, but in other cases I need to reuse the same tag to keep the versioning correct. I can always log into Gitlab or Github and manually delete it, but that’s a pain.

If you find yourself in this situation, you can remove a remote tag (1.2.3 in the example below) by executing:

git push origin :refs/tags/1.2.3

You can even combine this with the push of a new tag and/or branch:

git push --tags origin master :refs/tags/1.2.3

The : in the push tells Git to delete the object that follows. You can use this to delete remote branches as well:

git push origin :issue-123