Tags
A tag is a ref that, unlike a branch, doesn’t move — it permanently marks
one specific commit, most commonly used for release versions
(v1.0.0, v2.3.1).
Lightweight vs. annotated
| Lightweight | Annotated | |
|---|---|---|
| What it is | A plain pointer to a commit | A full object: tagger, date, message, optional GPG signature |
| Create with | git tag v1.0.0 | git tag -a v1.0.0 -m "Release 1.0.0" |
| Use for | Private, throwaway bookmarks | Public releases — almost always the right choice |
Creating tags
git tag v1.0.0 # lightweight, on HEAD
git tag -a v1.0.0 -m "Release 1.0.0" # annotated, on HEAD
git tag -a v0.9.0 <sha> -m "Retroactive tag" # annotated, on a specific commit
git tag -s v1.0.0 -m "Release 1.0.0" # GPG-signed annotated tag
Listing and inspecting
git tag # list all tags
git tag -l "v1.*" # filter by pattern
git show v1.0.0 # show the tag's message and the commit it points to
Pushing tags
Tags are not pushed by a plain git push — they need to be pushed
explicitly:
git push origin v1.0.0 # push one tag
git push origin --tags # push every local tag
git push --follow-tags # push commits + any annotated tags reachable from them
Checking out a tag
git checkout v1.0.0 # detached HEAD at that commit
git switch -c hotfix v1.0.0 # branch off a tag instead, if you'll commit
Deleting tags
git tag -d v1.0.0 # delete locally
git push origin --delete v1.0.0 # delete on the remote