When we work with Git, our project keeps growing with many commits. Sometimes we want to mark a specific moment in our project—like a version release, milestone, or stable point. This is where Git tags come in.
Git tags let us create meaningful labels for important commits, making them easy to find later.
1. What Are Git Tags?
A Git tag is a pointer to a specific commit—like a bookmark.
Developers commonly use tags to mark:
- Releases:
v1.0,v2.1.3 - Milestones:
beta,rc1(release candidate) - Special points:
initial-release,demo-version
Tags help you say:
👉 “This is a stable version of my code.”
2. Types of Git Tags
Git supports two types:
1. Lightweight Tags
A simple label pointing to a commit.
- No extra data
- Just a name
- Used for quick or temporary tagging
Example:
git tag v1.0
2. Annotated Tags (Recommended)
These include:
- Tagger name
- Date
- Message
- Optional GPG signature
They’re great for releases because they store more information.
Example:
git tag -a v1.0 -m "Release version 1.0"
3. Creating Tags
Create a lightweight tag
git tag v1.0
Create an annotated tag
git tag -a v1.0 -m "Release version 1.0"
4. Tagging Older Commits
You can tag any past commit by adding its commit ID:
git tag -a v0.9 3a4b2c1 -m "Old stable version"
5. Listing All Tags
git tag
Output example:
v0.9
v1.0
v1.1
v2.0-beta
You can also search for tags using wildcard patterns:
git tag -l "v1.*"
6. Pushing Tags to a Remote Repository
Push one tag
git push origin v1.0
Push all tags
git push --tags
Important:
Tags are not pushed automatically.
You must push them manually.
7. Checking Out a Tag
You can view the project as it was at the time of the tag:
git checkout v1.0
⚠️ This puts you in a detached HEAD state — meaning you’re not on a branch.
If you want to work from that tag:
git checkout -b new-branch-name v1.0
8. Deleting Tags
Delete locally
git tag -d v1.0
Delete from remote
git push origin --delete v1.0
9. Why Are Tags Useful?
✔ Easy to mark releases
Production releases are always tagged.
✔ Useful for CI/CD pipelines
Build tools use tags to trigger deployment based on version numbers.
✔ Helps track project history
You can easily compare versions, rollback, or test stable points.
✔ Works perfectly with semantic versioning
Examples:
v1.0.0v1.0.1v2.1.3
10. Real-World Use Cases for Git Tags
Tags aren’t just a Git feature — they’re an essential part of real-world software development.
Here are the most common scenarios:
A. Release Management (Most Common Use Case)
Imagine your team completes the first stable version of your app.
Before deploying it to production, you tag the release:
git tag -a v1.0 -m "First stable release"
git push origin v1.0
Why this matters
- CI/CD tools can auto-deploy based on the tag.
- Teams can revisit the exact code shipped in
v1.0. - Easy to compare versions:
git diff v1.0 v1.1
If there’s an issue in production:
git checkout v1.0
And the old version is instantly reproducible.
B. Client Demo or Milestone Build
Say you give a demo to a client.
You tag that commit:
git tag -a demo-jan-2025 -m "January demo build"
git push origin demo-jan-2025
Later, if someone asks:
“Can we rebuild the exact version we showed in January?”
You can reproduce it instantly.
C. Versioning for Libraries / Packages
If you’re publishing:
- NPM packages
- Python libraries
- Docker images
- Terraform modules
Versioning depends on tags like:
v1.0.0v1.1.2v2.0.0
Automation tools fetch code directly from tags.
D. Marking Important Events
Teams often tag:
- The first working prototype
- Security patches
- Hotfixes
- Internal review builds
Having these marked makes long-term maintenance much easier.
11. Summary Table
| Task | Command |
|---|---|
| List tags | git tag |
| Create lightweight tag | git tag v1.0 |
| Create annotated tag | git tag -a v1.0 -m "message" |
| Tag old commit | git tag -a v1.0 <commit> |
| Push tag | git push origin v1.0 |
| Push all tags | git push --tags |
| Delete local tag | git tag -d v1.0 |
| Delete remote tag | git push origin --delete v1.0 |
| Checkout tag | git checkout v1.0 |
Final Thoughts
Git tags make it easy to identify important points in your project’s history.
Whether you’re releasing version 1.0 or marking a demo milestone, tags help you keep your repository organized and professional.