Git Tag: Mark Releases and Important Commits
Learn how to create, list, and push git tags for versioning releases. Annotated vs lightweight tags and semantic versioning explained.
git tag -a v1.0.0 -m "Release version 1.0.0"Detailed Explanation
What Does git tag Do?
git tag creates a named reference to a specific commit. Tags are commonly used to mark release points (v1.0.0, v2.3.1) and provide stable reference points in your project history.
Annotated vs. Lightweight Tags
# Annotated tag (recommended for releases)
git tag -a v1.0.0 -m "Release version 1.0.0"
# Lightweight tag (just a pointer)
git tag v1.0.0-beta
Annotated tags store the tagger name, date, and message. They are full Git objects. Lightweight tags are simply pointers to a commit — use them for temporary or private markers.
Managing Tags
# List all tags
git tag -l
# List tags matching a pattern
git tag -l "v2.*"
# Show tag details
git show v1.0.0
# Tag a past commit
git tag -a v0.9.0 -m "Retroactive tag" abc1234
# Delete a local tag
git tag -d v1.0.0-beta
Pushing Tags to Remote
Tags are not pushed by default with git push. You must explicitly push them:
# Push a single tag
git push origin v1.0.0
# Push all tags
git push origin --tags
Deleting Remote Tags
git push origin --delete v1.0.0-beta
Semantic Versioning with Tags
Follow the MAJOR.MINOR.PATCH convention:
- MAJOR: Breaking changes
- MINOR: New features, backward-compatible
- PATCH: Bug fixes
Tags integrate with CI/CD pipelines — pushing a tag like v1.2.0 can automatically trigger a production deployment. They give your release process a clear, immutable reference point.
Use Case
A team is ready to ship version 2.0 of their application. They create an annotated tag on the release commit and push it to trigger the CI/CD deployment pipeline.