What is a Git tag, and what is the difference between lightweight and annotated tags?
Quick Answer
A tag marks a specific commit permanently — usually a release. A lightweight tag is just a name pointing at a commit. An annotated tag (git tag -a v1.2.0 -m "...") is a real object with a message, tagger and date, and can be GPG-signed. Use annotated tags for releases.
A tag is a permanent bookmark on a commit, and you use it for releases. A lightweight tag is literally just a label. An annotated tag is a proper Git object with its own message, author and timestamp, and it can be signed, so that's what I use for a real release — git tag -a v1.2.0. Tags don't get pushed automatically, so you have to git push origin v1.2.0, and a lot of CI pipelines trigger a release build when a version tag is pushed.
- Tags aren't pushed by default —
git push origin v1.2.0orgit push --tags. - Unlike a branch, a tag doesn't move — it's a fixed reference.
- CI often builds/publishes on a tag push; SemVer tags drive release automation.