git/tag-delete

Delete Tag

Delete local or remote tags

git
tag
delete
cleanup

Command

git tag -d <tag>

Explanation

The `git tag -d` command deletes a tag from your local repository. This is useful when a tag was created incorrectly or is no longer needed. Deleting a tag locally does not affect the remote repository. To remove a tag from the remote, use `git push origin --delete <tag>`. It’s good practice to ensure you’re not deleting tags that others depend on, especially in shared or production repositories.

Common Use Cases

  • Removing incorrect or outdated release tags
  • Cleaning up test tags before public release
  • Correcting tagging mistakes

Best Practices

  • Always confirm which tags are safe to delete before removal
  • Delete both local and remote tags if they’re obsolete
  • Communicate tag deletions to the team if working collaboratively

Common Mistakes to Avoid

  • Assuming deleting a local tag also removes it from the remote
  • Deleting tags without verifying if they are in use
  • Forgetting to remove remote tag after local deletion

Troubleshooting

Problem: Tag still visible on remote after deletion

Solution: You must remove it from remote manually using `git push origin --delete <tag>`.

Problem: Accidentally deleted important tag

Solution: Recreate the tag pointing to the correct commit using `git tag <tag-name> <commit-hash>` and re-push it.

Examples

Delete local tag v1.0

git tag -d v1.0

Delete tag v1.0 from remote repository

git push origin --delete v1.0

Delete both local and remote tag

git tag -d v1.0 && git push origin --delete v1.0