Signup/Sign In

How to Delete Local and Remote Tags on Git?

Tags are used in Git to mark specific points in the project history. This is done to easily identify those points in the future. Tags are mostly used to mark release versions of a project. Tags can be local to just our machine or we can push these tags to the remote repository. But there may be cases where we don't need those tags anymore. Let's learn how to delete tags in Git.

Deleting a tag

Deleting Local Tags

Local tags are tags that we have created on our system and are not pushed to any remote repositories. They exist just on our local machine. We can delete such tags by using the Git Tag command along with the -d flag which is short for delete.

$ git tag -d <tag-name>

This command should give output as follows.

Deleting a local tag

The highlighted part shows a hash. In the case of lightweight tags, this denotes the hash of the object to which the tag points. In the case of annotated tags, it is the hash of the tag object itself.

Deleting Remote Tags

Tags that are pushed to the remote repository are known as remote tags. Whenever someone clones that repository then the tags will also get cloned. To delete a tag from your remote repository we need to use the --delete or -d flag along with the Git Push command.

$ git push --delete <remote-name> <tag-name>

You will be asked to sign in to the website where your remote repository is hosted.

There is another way to delete the remote branch using the Git Push command. This is used in cases where a tag's name is the same as some branch's name. Since the syntax of deleting a remote branch is the same as that of deleting a tag, so we prefer to use the following command instead.

$ git push <remote-name> :refs/tags/<tag-name>


Tags are an important part of any repository as they provide additional information about the history of our project. Deleting tags is pretty straightforward. We can delete a local tag by simply using the -d flag with the Git Tag command. To delete a remote tag we can use the Git Push command as discussed above. I hope this tutorial helped you in deleting your tags.