What is the difference between a lightweight tag and an annotated tag, and when should you use each?
Last updated
A lightweight tag is just a name pointing straight at a commit, like a branch that never moves. An annotated tag is a full object storing metadata (message, tagger, date) and can be GPG-signed. Use annotated tags for releases; lightweight tags for private, temporary bookmarks.
Lightweight tag:
Created with
git tag <name>(no-a/-m).Just a ref pointing to a commit: no author, date, or message.
Annotated tag:
Created with
git tag -a v1.0 -m "..."(or-sto sign).Creates a tag object with tagger, timestamp, message, and optional signature.
When to use each:
Annotated: public releases: they carry provenance and are what
git describeprefers by default.Lightweight: throwaway local markers you don't need to audit.
- https://git-scm.com/book/it/v2/Git-Basics-Tagging
- https://www.atlassian.com/git/tutorials/inspecting-a-repository/git-tag
- https://www.freecodecamp.org/news/learn-git-basics/
- https://medium.com/@ahmed.ally2/the-complete-guide-to-git-tags-version-your-projects-like-a-pro-29e90ec30449
- https://www.freecodecamp.org/news/git-tag-explained-how-to-add-remove/
- https://dev.to/mrdanishsaleem/understanding-git-tags-an-essential-tool-for-version-control-3jdc
- https://www.dolpa.me/annotated-vs-lightweight-tags-in-git-which-one-should-you-use/
- https://rajeshblogs.medium.com/git-tag-showdown-lightweight-vs-annotated-vs-signed-5303eb2e7be0