How do you delete a lightweight tag?
Posted by BobHarris
Last Updated: June 11, 2024
To delete a lightweight tag in Git, you can use the following command:
git tag -d <tag_name>
Replace <tag_name> with the name of the tag you want to delete. For example, if your tag is named v1.0, you would use:
git tag -d v1.0
This command will only delete the tag from your local repository. If the tag has already been pushed to a remote repository and you want to delete it from there as well, you'll have to use the following command:
git push origin --delete <tag_name>
So, for example, to delete the v1.0 tag from the remote named origin, you would run:
git push origin --delete v1.0
Make sure to replace origin with the appropriate name of your remote if it’s different.
Summary
1. Delete a local tag:
git tag -d <tag_name>
2. Delete a remote tag:
git push origin --delete <tag_name>