TExcelTAD
Home › Git › Git Tagging

Git Tagging

A tag is a permanent, human-friendly name for one specific commit. Tags are mostly used for releases: v1.0.0, v2.3.1. Unlike a branch, a tag does not move when you make new commits.

Lightweight and annotated tags

Type Create with Stores
Lightweight git tag v1.0 just a name pointing at a commit
Annotated git tag -a v1.0 -m "message" a full tag object: tagger, date, message (and optionally a signature)

Annotated tags are recommended for releases, because they record who tagged the release and why. Lightweight tags are fine for private bookmarks.

bash · try it yourself
mkdir app && cd app
git init -q
echo "version 1" > app.txt && git add app.txt && git commit -q -m "First release"
git tag -a v1.0.0 -m "First public release"
echo "version 1.1" > app.txt && git commit -q -am "Add dark mode"
git tag try-dark-mode
git tag
echo "---"
git log --oneline --decorate
try-dark-mode
v1.0.0
---
f27bdad (HEAD -> main, tag: try-dark-mode) Add dark mode
454162f (tag: v1.0.0) First release

git tag lists tags alphabetically. --decorate (the default in a terminal) shows which names point at each commit.

Inspecting a tag

git show on an annotated tag prints the tag's own information first, then the commit it points to:

bash · try it yourself
mkdir app && cd app
git init -q
echo "version 1" > app.txt && git add app.txt && git commit -q -m "First release"
git tag -a v1.0.0 -m "First public release"
git tag quick
git show --no-patch v1.0.0
echo "--- lightweight:"
git show --no-patch --oneline quick
echo "--- object types:"
git cat-file -t v1.0.0
git cat-file -t quick
tag v1.0.0
Tagger: Ada Lovelace <ada@example.com>
Date:   Thu Jan 15 10:00:00 2026 +0000

First public release

commit 454162faa97e4d2023dbf98e142417b4d33f271d
Author: Ada Lovelace <ada@example.com>
Date:   Thu Jan 15 10:00:00 2026 +0000

    First release
--- lightweight:
454162f First release
--- object types:
tag
commit

The annotated tag is its own object (tag) that points to the commit; the lightweight tag is only a reference to the commit itself.

Tagging an older commit and listing with a pattern

You can tag any commit by giving its hash or another reference. git tag -l accepts a pattern, and -n shows the first line of each annotation:

bash · try it yourself
mkdir app && cd app
git init -q
for v in 1 2 3; do
  echo "build $v" > app.txt; git add app.txt; git commit -q -m "Build $v"
done
git tag -a v0.1 -m "Alpha" HEAD~2
git tag -a v0.2 -m "Beta" HEAD~1
git tag -a v1.0 -m "Stable"
git tag -l "v0.*" -n
echo "---"
git describe --tags
echo "build 4" > app.txt && git commit -q -am "Build 4"
git describe --tags
v0.1            Alpha
v0.2            Beta
---
v1.0
v1.0-1-g30a9bff

git describe names the current commit relative to the nearest tag: v1.0-1-g… means "one commit after v1.0", followed by g and the short hash. Build scripts often embed this string as a version number.

Pushing and deleting tags

Tags are not pushed by git push on its own. Push one with git push origin v1.0.0, or all with git push --tags. Here a local bare repository plays the role of GitHub:

bash · try it yourself
git init -q --bare ~/remote.git
mkdir app && cd app
git init -q
echo "v1" > app.txt && git add app.txt && git commit -q -m "Release"
git tag -a v1.0.0 -m "Release 1.0.0"
git tag wrong-tag
git remote add origin ~/remote.git
git push -q origin main
git push origin v1.0.0
git tag -d wrong-tag
git ls-remote --tags origin
To /home/learner/remote.git
 * [new tag]         v1.0.0 -> v1.0.0
Deleted tag 'wrong-tag' (was fcc4ef7)
1843a04b1afa06a38f698aa0b1db875cc28812d2	refs/tags/v1.0.0
fcc4ef73fe4d67af29b4780af198cad8bbb9e605	refs/tags/v1.0.0^{}

git ls-remote lists what the remote has. An annotated tag appears twice: the tag object itself, and a ^{} line with the commit it points to ("peeled"). wrong-tag was never pushed, so deleting it locally was enough.

Warning: Don't move or re-create a tag that others have already fetched. People who downloaded the old tag will not get the new one automatically. Release a new version number instead.

Semantic versioning

Most projects name release tags with SemVer: vMAJOR.MINOR.PATCH. Increase MAJOR for breaking changes, MINOR for new backwards-compatible features and PATCH for bug fixes. For example, v2.4.1 → v2.5.0 adds a feature, v2.5.0 → v3.0.0 breaks compatibility.

Test yourself

Which command creates an annotated tag?

  1. git tag v1.0
  2. git tag -a v1.0 -m "Release"
  3. git branch v1.0
  4. git commit --tag v1.0

You run git push origin main. Are your new tags pushed too?

  1. Yes, always
  2. No, tags are pushed separately (git push origin <tag> or --tags)
  3. Only lightweight tags
  4. Only annotated tags

What does v2.1-3-gabc1234 from git describe mean?

  1. Version 2.1.3
  2. Three commits after tag v2.1, at commit abc1234
  3. Tag v2.1 on branch 3
  4. Three tags named v2.1