Git Deleting Remote Tags from the Git Server

Posted on In Software, Tutorial

Git’s tags are convenient use to name some specific commits by tagging them for releasing or book keeping purposes. For example, GitHub allows repository managers to make releases using git tags. However, it may happen by mistake that a git tag is pushed to the remote git server while the tag has been made to a wrong commit, such as when a release tag is added the HEAD of a wrong branch. Under such cases, we may want to delete the remote git tag from the git server.

As a common practise, we assume the origin remote target is the remote git server target we would like to delete the remote git tag from.

Delete a Remote Git Tag from the Git Server

To delete a remote git tag TAG, run

git push --delete origin TAG

If the git repository uses the same name for some tags and branches (because git tags and branches are in different namespace and a tag and a branch can have the same name), use the full ref as follows.

git push --delete origin refs/tags/TAG

Note: after deleting the remote git tag, the locally cloned repository still has the tag. The local git tag can be removed by git tag -d TAG.

Example: Delete a Remote Git Tag v1.1.1

For example, to remove the tag v1.1.1, run

$ git push --delete origin v1.1.1

On success, git will print output as follows.

To github.com:user/repo
 - [deleted]         v1.1.1

Please note, the remote tag deletion operation is not a commit and this operation is not revertible.

Leave a Reply

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