Git

Tags

Git · 8 entries

Create a Lightweight Tag

syntax
git tag <name> [commit]
example
git tag v1.0.0
git tag v0.9.0 a1b2c3d

Note Lightweight tags are just pointers to a commit — no extra metadata. For releases, prefer annotated tags which include author, date, and a message.

Create an Annotated Tag

syntax
git tag -a <name> -m "message" [commit]
example
git tag -a v2.0.0 -m "Major release: new payment system"
git tag -a v1.5.0 -m "Performance improvements" a1b2c3d

Note Annotated tags store the tagger's name, email, date, and a message. They're full Git objects. Use these for releases so you have a record of who tagged and why.

List Tags

syntax
git tag [-l "pattern"]
example
git tag
git tag -l "v2.*"
output
v1.0.0
v1.5.0
v2.0.0
v2.1.0

Note Use -l with a glob pattern to filter. Combine with --sort=-version:refname to sort by semantic version descending.

Push Tags to Remote

syntax
git push origin <tag>
git push origin --tags
example
# Push a single tag:
git push origin v2.0.0

# Push all tags:
git push origin --tags
output
To https://github.com/user/project.git
 * [new tag]         v2.0.0 -> v2.0.0

Note Tags are NOT pushed automatically with git push. You must explicitly push them. --tags pushes all local tags that don't exist on the remote.

Delete a Tag

syntax
git tag -d <tag>
git push origin --delete <tag>
example
# Delete locally:
git tag -d v1.0.0-beta

# Delete from remote:
git push origin --delete v1.0.0-beta
output
Deleted tag 'v1.0.0-beta' (was a1b2c3d)

Note You must delete a tag both locally and on the remote — they're independent. Other collaborators who already fetched the tag will still have it until they prune.

Checkout a Tag

syntax
git checkout <tag>
example
git checkout v2.0.0
output
Note: switching to 'v2.0.0'.
You are in 'detached HEAD' state.

Note Checking out a tag puts you in detached HEAD state — you're not on any branch. To make changes, create a branch from the tag: git switch -c hotfix/v2.0.1

View Tag Details

syntax
git show <tag>
example
git show v2.0.0
output
tag v2.0.0
Tagger: Samira Khan <samira@example.com>
Date:   Mon Mar 30 14:22:01 2026 +0000

Major release: new payment system

commit a1b2c3d...
...

Note For annotated tags, shows the tagger info and message plus the commit it points to. For lightweight tags, just shows the commit.

Find the Latest Tag

syntax
git describe --tags --abbrev=0
git describe --tags
example
git describe --tags --abbrev=0
git describe --tags
output
v2.0.0
v2.0.0-3-ga1b2c3d

Note --abbrev=0 gives just the tag name. Without it, Git also shows how many commits since that tag and the current abbreviated hash. Useful in CI/CD for version stamping.