Git Tag Deletion Explained — Local, Remote, and Retagging

In the last few blogs, we learned:

  • How to create lightweight tags
  • How to create annotated tags
  • How to push tags to GitHub

Now let’s see how to delete tags — both locally and on GitHub — and how to fix tags if they are attached to the wrong commit.


Deleting a Tag Locally

First, list all tags:

git tag

Suppose you want to delete the tag v1.1:

git tag -d v1.1

👉 This removes the tag only from your local repository.

Check again:

git tag

v1.1 is gone locally. But the tag still exists on GitHub.


Deleting a Tag from Remote

To remove it from GitHub, push a delete request:

git push origin --delete v1.1

or

git push origin :v1.1

👉 After running this, refresh GitHub and the tag will be removed from the remote repository.


Creating a Tag on a Specific Commit

By default, when you run:

git tag v2.5

👉 The tag is created on the commit where HEAD is currently pointing.

But you can also tag a specific commit by giving its commit ID:

git tag v2.5 <commit-id>

✅ This attaches v2.5 to that commit, not the latest one.


Fixing a Wrongly Created Tag

What if you tagged the wrong commit?

Two options:

  1. Delete the tag and recreate it.
  2. Or simply force update the tag:
git tag -f v2.5 <correct-commit-id>

👉 This moves the tag pointer to the correct commit.


Summary

  • git tag -d <tag> → Deletes a tag locally.
  • git push origin --delete <tag> or git push origin :<tag> → Deletes a tag from GitHub.
  • Tags can be created on specific commits using the commit ID.
  • Use git tag -f to move (retag) a tag to another commit.
  • Local and remote tag deletions are independent.

Keep Learning 🚀

👉 Subscribe to Learning Ocean – Subscribers get coupon codes for my courses, early access to blogs and courses, and even exclusive YouTube videos.

👉 My YouTube Channel – More videos, more fun, and lots of learning!

👉 📺 Watch this topic in video form

Stay curious, keep coding, and let’s make learning fun together! 🎉