git tag
intermediatePlant a permanent, named marker on a commit.
What it does
git tag creates an immutable name pointing at a specific commit — v1.0.0, v2.3.1 — a release anchor that branches are free to move away from. Lightweight tags are just a ref file with a hash; annotated tags are full objects with message, tagger and date.
A tag pins a commit forever, indifferent to branch movement
Watch it — press play
A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.
Step 1
Freeze a milestone
You shipped v1.0.0. A branch would drift — you need a name that never moves.
git tag -a v1.0.0 -m "production release"Time to pin this moment
Under the hood
Lightweight: a ref that never moves
`git tag v1.0.0` writes a file refs/tags/v1.0.0 containing a commit hash. Same mechanism as a branch, minus the movement: tags are not updated by any commit.
Annotated: a full tag object
`git tag -a v1.0.0 -m "release"` creates a TAG OBJECT (type tag) that holds tagger, message, date, and points to the commit. The ref then points at the tag object — richer, cryptographically signed (git tag -s) metadata.
Tags move with clones if you push them
Tags aren't pushed by default with the branch push. `git push --follow-tags` (or --tags) ships them. Cloning brings every reachable tag, so releases travel with the repo.
Aliases the pros type
Memorize the git tag concept, then let one of these shortcuts make it instant. Aliases are real git config keys — add one with:
git config --global alias.st # → git tag -a -mg tggit tag -a -mAnnotated tag with message in one alias.
g tgpgit push origin --follow-tagsPublish your tags alongside the branch push.
g tglgit tag -lList all tags quickly.
Command anatomy
-a + -mAnnotated tag with a release message.
-sSign the tag with your GPG key (provenance!).
push origin --tagsPublish tags to the remote.
listShow all tags, lexically ordered.
When to reach for it
Marking releases: v1.0.0, v2.1.3 — the only true immovable milestones.
Rollback anchors: git checkout v1.2.0 to run a released state.
The npm/package.json version bump paired with a matching tag.
Pro tip
`git describe` reads the nearest tag a commit is downstream of — it's how many tools (and git itself) produce human-ish version strings like v1.2.0-4-g8a9f7c1 (4 commits after v1.2.0).