git-delete-tag
Delete tags from the local repository
TLDR
Delete a tag
SYNOPSIS
Local deletion:
git tag -d <tagname> [...]
Remote deletion:
git push --delete <remote> <tagname> [...]
PARAMETERS
-d, --delete
Used with git tag to delete the specified tag(s) from the local repository.
--delete
Used with git push to delete the specified ref(s) (in this case, tags) from the remote repository.
<tagname>
The name of the tag (or multiple tag names) to be deleted.
<remote>
The name of the remote repository (e.g., 'origin') from which to delete the tag. This is required for remote deletion.
DESCRIPTION
The concept of 'git-delete-tag' encompasses two primary operations in Git: deleting a tag from your local repository and deleting a tag from a remote repository.
To delete a tag locally, you use the git tag -d command. This removes the tag reference from your local Git repository. However, it's crucial to understand that deleting a local tag does not automatically remove it from any remote repositories it may have been pushed to.
To delete a tag from a remote repository (e.g., 'origin'), you must explicitly push a deletion command using git push --delete. This command tells the remote to remove the specified tag. Only after both local and remote deletions are performed will the tag be fully removed from your working environment and the shared repository.
CAVEATS
Deleting a tag locally only removes its reference from your local repository; it does not remove it from any remote repositories it might have been pushed to. Similarly, deleting a tag from a remote does not remove it from other local repositories that have fetched it unless those repositories explicitly delete it themselves. Users with appropriate permissions can recreate a deleted tag if needed, potentially pointing to a different commit.
WHEN TO DELETE TAGS
Tags are typically deleted when they were created by mistake (e.g., typo in tag name), are no longer relevant (e.g., an experimental tag), or need to be moved to a different commit (though this is less common for annotated tags that represent releases).
ANNOTATED VS. LIGHTWEIGHT TAGS
While both types of tags can be deleted using these methods, annotated tags (created with -a or -s) are full Git objects that include a tagger name, email, date, and a message, similar to a commit. Lightweight tags are simply pointers to a specific commit. The deletion process is the same for both.
HISTORY
Tagging has been a fundamental feature of Git since its inception, allowing users to mark significant points in history (like release versions). The ability to delete tags, both locally and remotely, was introduced to provide full lifecycle management for these references, allowing for correction or removal of erroneously created or obsolete tags.
SEE ALSO
git tag(1), git push(1), git fetch(1)