How to delete Git tags?
Marc Wagner
October 28, 2020
In Git, tags are used to mark “commits” that are more important than others. They are used, for example, to highlight important events such as bug fixes and releases.
Now and then, of course, it can happen that you want to delete a tag again, for whatever reason.
Deleting local Git tags #
To delete a local tag you can use the following command:
git tag -d <tag_name>
I usually name my tags after the version of the application, e.g.: v0.15. So now if I want to delete exactly this tag, I enter the following:
git tag -d v0.15
If you are no longer sure which name you used, you can simply view your tags as follows:
git tag -l
You will also get a message if you specify a tag that does not exist:
error: tag <tag_name> not found.
Deleting Git tags in the remote directory #
To delete a Git tag from a remote directory, you can specify the following command:
git push --delete <branch> <tag_name>
For example, if you want to delete the tag “v0.15” from the branch “master” you can do this as follows:
git push --delete origin/master v0.15
I hope this article could help you. If you have any questions or feedback, feel free to leave a comment.
Artikel von:
Marc Wagner
Hi Marc here. I’m the founder of Forge12 Interactive and have been passionate about building websites, online stores, applications and SaaS solutions for businesses for over 20 years. Before founding the company, I already worked in publicly listed companies and acquired all kinds of knowledge. Now I want to pass this knowledge on to my customers.