Git Tags Cheat Sheet

Git tags — lightweight vs annotated tags, creating, listing, pushing, deleting, checking out, signing tags with GPG, and release management.

Last Updated: May 1, 2025

Tag Commands

git tag
List all tags alphabetically
git tag -l 'v2.*'
List tags matching a pattern (use wildcards)
git tag v1.0.0
Create a lightweight tag at current HEAD
git tag -a v1.0.0 -m Release message
Create an annotated tag with message
git tag -a v1.0.0 commit -m msg
Tag a specific commit (not HEAD)
git show v1.0.0
Show full tag details: tagger, date, message, commit
git tag -d v1.0.0
Delete a local tag
git push origin --delete v1.0.0
Delete a remote tag

Pushing & Sharing Tags

git push origin v1.0.0
Push a single tag to remote
git push origin --tags
Push ALL local tags to remote
git push --follow-tags
Push commits AND any annotated tags that reference them
git fetch --tags
Fetch all tags from remote
git tag -l --sort=-creatordate
List tags sorted by creation date (newest first)
git tag -l --sort=-version:refname
Sort tags semantically (v2.0 after v1.10)
git ls-remote --tags origin
List all tags on remote without fetching
git push origin :refs/tags/v1.0.0
Alternative syntax to delete a remote tag

Checking Out Tags

git checkout v1.0.0
Check out a tag (you'll be in detached HEAD state)
git checkout -b branch-from-tag v1.0.0
Create a branch from a tag (safer)
git switch --detach v1.0.0
Detach HEAD at a specific tag
git describe --tags
Show the most recent tag reachable from HEAD
git describe --tags --abbrev=0
Show only the tag name, no commit suffix
git describe --tags --dirty
Append '-dirty' if working tree has changes

Signed Tags (GPG)

git tag -s v1.0.0 -m Release
Create a GPG-signed tag
git tag -v v1.0.0
Verify a signed tag's GPG signature
git config --global user.signingkey KEYID
Set default GPG key for signing
git tag -a --sign v1.0.0 -m Release
Create annotated AND signed tag
git config --global tag.gpgSign true
Sign all tags automatically
gpg --list-secret-keys --keyid-format LONG
Find your GPG key ID
Pro Tip: Always use annotated tags for releases (`git tag -a`). They store the tagger, date, and message — lightweight tags are just pointers.