In software development, tracking specific versions of your code is essential — especially when it comes to releases, rollbacks, or debugging. That’s where Git tags come in.
In this post, you’ll learn what Git tags are, why they’re important, and how to create, manage, and delete them effectively.
🎯 What Is a Git Tag?
A Git tag is a reference to a specific point in Git history, usually used to mark releases (like v1.0
, v2.5.3
, etc.). Unlike branches, tags are not meant to change — they are typically used to label a commit for future reference.
There are two types of tags:
- Lightweight tags – simple bookmarks to a commit (like a branch that doesn’t move).
- Annotated tags – full objects in Git, stored permanently with metadata like tagger name, date, and message.
✅ Why Use Tags?
- Marking release versions (
v1.0.0
,v2.1.4
) - Creating checkpoints in project history
- Simplifying rollbacks or comparisons between versions
- Deploying specific builds in CI/CD pipelines
🔧 How to Create a Tag in Git
➤ 1. Create a Lightweight Tag
git tag v1.0
This tags the latest commit on the current branch with v1.0
.
➤ 2. Create an Annotated Tag (Recommended)
git tag -a v1.0 -m "Release version 1.0"
This creates a tag object with a message and metadata. Annotated tags are the best choice for versioning releases.
➤ 3. Tag a Specific Commit
First, find the commit hash:
git log --oneline
Then tag it:
git tag -a v0.9 abc1234 -m "Tagging old version"
🌐 How to Push Tags to GitHub
Tags are not pushed automatically with commits. You must push them manually:
git push origin v1.0
Or push all tags at once:
git push origin --tags
📋 List All Tags
To see all tags in your repository:
git tag
You can also filter tags by name:
git tag -l "v1.*"
❌ How to Delete a Tag
➤ Delete a Local Tag
git tag -d v1.0
➤ Delete a Remote Tag
git push origin --delete tag v1.0
🔍 Checkout a Tag (Read-Only)
If you want to view the code at a specific tag:
git checkout v1.0
⚠️ This puts you in a detached HEAD state. You’re not on a branch, so changes won’t be saved unless you create a new branch.
To create a branch from a tag:
git checkout -b new-branch-name v1.0
🧠 Summary of Git Tag Commands
Task | Command |
---|---|
Create lightweight tag | git tag v1.0 |
Create annotated tag | git tag -a v1.0 -m "Release v1.0" |
List all tags | git tag |
Push a tag | git push origin v1.0 |
Push all tags | git push origin --tags |
Delete a tag locally | git tag -d v1.0 |
Delete a tag remotely | git push origin --delete tag v1.0 |
🚀 Final Thoughts
Tags are a powerful way to mark important milestones in your Git repository — especially for version control, releases, and deployment pipelines. Whether you’re managing open-source libraries or enterprise software, mastering Git tags will make your workflow cleaner and more efficient.