How can I delete a remote tag with Git?

To delete a remote tag in Git, use one of these methods:

Method 1: Delete a Single Remote Tag

git push --delete origin <tag-name>

or the equivalent shorthand:

git push origin :refs/tags/<tag-name>

Example:

git push --delete origin v1.2.0
# or
git push origin :refs/tags/v1.2.0

Method 2: Delete Multiple Remote Tags

List tags separated by spaces:

git push --delete origin v1.2.0 v1.3.0

Step-by-Step Workflow

  1. Delete the remote tag (as shown above).
  2. (Optional) Delete the local tag (if it exists):
   git tag -d <tag-name>

Verify Deletion

Check if the tag was removed from the remote:

git ls-remote --tags origin

Key Notes

  • Replace origin with your remote name (e.g., upstream).
  • Git versions ≥1.7.0 support --delete for clarity.
  • If you see remote: error: refusing to delete the current branch, double-check the tag name.

Why This Works

  • The git push --delete command removes the reference to the tag on the remote.
  • The :refs/tags/<tag-name> syntax tells Git to push “nothing” to the tag’s location, effectively deleting it.

Leave a Reply

Your email address will not be published. Required fields are marked *