How to remove a tag from a commit in Git

When working with Git, you often use tags to mark versions - for example, v1.0.0.0. But what do you do if you put a tag on the wrong commit or just need to clean it up?

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_NAME

Example:

git tag -d v1.0.0

Remove 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_NAME

2. Remove on remote:

git push origin :refs/tags/TAG_NAME

Example:

git push origin :refs/tags/v1.0.0.0

Move 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_NAME

One-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_NAME

That'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.