Tag Types

Lightweight Versus Annotated Tags

Git 1,932 has two kinds of tag. A lightweight tag is only a ref, refs/tags/<name>, holding a commit hash, exactly like a branch that never moves. An annotated tag is a ref to a tag object: a fourth object type (after blobs, trees and commits, The Object Model) that stores the tagger, a date, a message and optionally a signature. Make one of each and look inside:

A lightweight and an annotated tag, and the objects behind themShell
git tag try-light
git tag -a try-annotated -m "A tag with its own object"
git cat-file -t try-light
git cat-file -t try-annotated
git cat-file -p try-annotated
git tag -d try-light try-annotated
Output
commit
tag
object a2508dab6ff752b05655d0c7ff254b7e2d4703cf
type commit
tag try-annotated
tagger Sam Rivera <sam@example.com> 1790305200 +0800
A tag with its own object
Deleted tag 'try-light' (was a2508da)
Deleted tag 'try-annotated' (was c4f1278)

The lightweight tag resolves straight to the commit; the annotated one to a tag object, c4f1278, that points at the commit (10). Git's documentation states the rule: annotated tags are for releases, lightweight tags for private or temporary labels. git describe and git push --follow-tags skip lightweight tags by default.

A lightweight tag points at a commit; an annotated tag points at a tag object
A lightweight tag points at a commit; an annotated tag points at a tag object