tag
remote
git

How can I delete a remote tag?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

To delete a remote tag in Git, you need to follow these steps:

1. Delete the Tag Locally (Optional)

First, you can delete the tag locally using the git tag -d command. This step is optional, but it helps keep your local repository clean.

bash
git tag -d <tagname>

Replace <tagname> with the name of the tag you want to delete.

Example:

bash
git tag -d v1.0.0

2. Delete the Tag from the Remote Repository

To delete the tag from the remote repository, you can use the git push command with the :refs/tags/<tagname> syntax.

bash
git push origin :refs/tags/<tagname>

Replace <tagname> with the name of the tag you want to delete.

Example:

bash
git push origin :refs/tags/v1.0.0
  • Explanation:
    • origin: The name of the remote repository. Replace this with your remote's name if it's different.
    • :refs/tags/v1.0.0: The colon (:) before refs/tags/v1.0.0 tells Git to delete the tag on the remote.

3. Verify the Deletion

You can verify that the tag has been deleted from the remote repository by running:

bash
git ls-remote --tags origin

This command lists all tags in the remote repository, allowing you to confirm that the specified tag has been removed.

Summary

  • Delete Locally: git tag -d <tagname> (optional)
  • Delete Remotely: git push origin :refs/tags/<tagname>

This process ensures that the tag is removed both locally (if you choose to) and from the remote repository.


Course illustration
Course illustration

All Rights Reserved.