TExcelTAD
Home › Release Engineering & CI/CD › Annotated vs Lightweight Tags

Annotated vs Lightweight Tags

A tag is how a version number becomes a commit. Git has two kinds, and release tooling treats them differently. The Git Tagging lesson introduces both; this lesson looks at them as a release engineer does: which one to use for releases, which commands ignore which kind, and why a published tag must never move.

Two kinds of tag

Lightweight tag Annotated tag
Created by git tag v1.0.0 git tag -a v1.0.0 -m "…" (or -s to sign)
What it is just a ref (refs/tags/v1.0.0) pointing at a commit a ref pointing at a tag object, which points at the commit
Stores nothing but the commit id tagger name, email, date, message, optional signature
Seen by git describe (default) no yes
Pushed by git push --follow-tags no yes
Meant for private bookmarks releases

The session creates one of each on the same commit and asks Git what they are:

bash · try it yourself
mkdir app && cd app && git init -q
echo "v1" > app.txt && git add app.txt && git commit -q -m "feat: first version"
git tag bookmark
git tag -a v1.0.0 -m "Release 1.0.0"
echo "--- object types"
git cat-file -t bookmark
git cat-file -t v1.0.0
echo "--- the annotated tag object"
git cat-file -p v1.0.0
echo "--- both resolve to the same commit"
git rev-parse --short 'bookmark^{commit}'
git rev-parse --short 'v1.0.0^{commit}'
echo "--- listing with type and message"
git for-each-ref refs/tags --format='%(refname:short) %(objecttype) %(contents:subject)'
--- object types
commit
tag
--- the annotated tag object
object c61f06655dbc9a072a34244d6a8ede44df567dfe
type commit
tag v1.0.0
tagger Ada Lovelace <ada@example.com> 1768471200 +0000

Release 1.0.0
--- both resolve to the same commit
c61f066
c61f066
--- listing with type and message
bookmark commit feat: first version
v1.0.0 tag Release 1.0.0

An annotated tag has its own object id, different from the commit's, which is why git ls-remote in the intro showed two lines per tag: the tag object and the peeled commit (^{}). ^{commit} peels a tag down to its commit; scripts that compare a tag with HEAD must peel, or they compare a tag object with a commit and never match.

What tools see

bash · try it yourself
mkdir app && cd app && git init -q
c() { echo "$1" >> app.txt; git add app.txt; git commit -q -m "$1"; }
c "feat: one"; git tag -a v1.0.0 -m "Release 1.0.0"
c "feat: two"; git tag v1.1.0-light
c "fix: three"
echo "describe (annotated only): $(git describe)"
echo "describe --tags (any tag): $(git describe --tags)"
git init -q --bare ../remote.git && git remote add origin ../remote.git
git push -q --follow-tags origin main
echo "--- on the remote after --follow-tags"
git ls-remote --tags origin | cut -f2
describe (annotated only): v1.0.0-2-g0b4a17c
describe --tags (any tag): v1.1.0-light-1-g0b4a17c
--- on the remote after --follow-tags
refs/tags/v1.0.0
refs/tags/v1.0.0^{}

git describe skipped the lightweight tag and measured from v1.0.0, and --follow-tags didn't push v1.1.0-light. If a release script creates lightweight tags, both of these silently do the wrong thing. Release tags are annotated; semantic-release, git-cliff and changesets all handle annotated tags, and git tag -a is the habit to build.

Tags are immutable (by convention, then by policy)

A tag can be moved: git tag -f v1.0.0 <other-commit> followed by git push -f origin v1.0.0. Don't:

  • Everyone who already fetched v1.0.0 keeps the old commit. git fetch does not overwrite an existing local tag that differs from the remote one; it reports would clobber existing tag and leaves it. Two people can now build "1.0.0" from different sources.
  • Package registries, Go's checksum database and caches have recorded the old content. A Go module whose tag moved fails verification for everyone with verifying module: checksum mismatch.
  • Your checksums and signatures no longer match what the tag points to.

The session shows the first problem on a local clone:

bash · try it yourself
git init -q --bare remote.git
git clone -q remote.git dev 2>/dev/null && cd dev
echo 1 > f && git add f && git commit -q -m "feat: one" && git tag -a v1.0.0 -m "1.0.0"
git push -q origin main v1.0.0
cd .. && git clone -q remote.git user && cd dev
echo 2 > f && git commit -q -am "fix: oops, forgot this"
git tag -f -a v1.0.0 -m "1.0.0 (moved)"
git push -q -f origin main v1.0.0
cd ../user
git fetch --tags origin 2>&1 | sed 's/^ *//'
echo "user's v1.0.0 -> $(git rev-parse --short 'v1.0.0^{commit}')"
echo "remote v1.0.0 -> $(git ls-remote origin 'refs/tags/v1.0.0^{}' | cut -c1-7)"
Updated tag 'v1.0.0' (was bc6ce18)
From /home/learner/remote
12f7a7a..0851e52  main       -> origin/main
! [rejected]        v1.0.0     -> v1.0.0  (would clobber existing tag)
user's v1.0.0 -> 12f7a7a
remote v1.0.0 -> 0851e52

The right fix for "we tagged too early" is a new version: release 1.0.1. Hosting platforms let you enforce this: GitHub rulesets can block updating and deleting tags matching v*, GitHub's immutable releases lock a published release's tag and assets, and GitLab has protected tags. Turn them on for release tags on day one.

Naming conventions

Convention Example Used by
v + SemVer v1.4.2 most projects; required by Go modules
bare SemVer 1.4.2 some Java/Python projects
package-scoped @acme/core@1.3.0, core-v1.3.0, core/v1.3.0 monorepos (changesets writes the first form; Go needs the last form for a module in a subdirectory)
CalVer 2026.1.0 apps, distros

Pick one, write it down, and configure every tool with it (tagFormat in semantic-release, tag_pattern in git-cliff). Mixing v1.4.2 and 1.4.3 in one repository breaks "find the previous release" logic in most tools.

Test yourself

Why should release tags be annotated?

  1. Lightweight tags can't be pushed
  2. Annotated tags store who/when/why, are seen by git describe and are pushed by --follow-tags
  3. Annotated tags are smaller
  4. Only annotated tags can point at merge commits

You force-moved a published tag. What happens on a teammate's clone that already had it?

  1. git fetch --tags updates it silently
  2. git fetch refuses to clobber the existing tag, so they keep the old commit
  3. Their repository is corrupted
  4. Git deletes the tag

What does v1.0.0^{commit} mean?

  1. The parent of the tagged commit
  2. Peel the tag (object) down to the commit it points at
  3. All commits since v1.0.0
  4. The tag's message