How to remove a tag from a commit in Git
Here I'll walk you through how to remove or move a roof - both locally and remotely.
Remove a roof locally
If the tag only exists in your local repository:
git tag -d TAG_NAMEExample:
git tag -d v1.0.0Remove a tag on the remote
If you have already pushed the tag to remote (e.g. GitHub or GitLab), it should be deleted in both places.
1. remove locally:
git tag -d TAG_NAME2. Remove on remote:
git push origin :refs/tags/TAG_NAMEExample:
git push origin :refs/tags/v1.0.0.0Move a roof to another commit
Do you want the tag to point to another commit instead? Then you can force it to move:
git tag -f TAG_NAME
git push origin -f TAG_NAMEOne-liner to remove locally and remotely
If you want to save a few steps:
git tag -d TAG_NAME && git push origin :refs/tags/TAG_NAMEThat's it! This is how you can clean up Git tags.
- Tags are often used for versioning, so it can cause confusion if you delete or move them after others have downloaded them.
- Make sure your team knows that a tag has been changed or removed.