In Git, tags are used to mark specific points in history as being important—typically to denote release versions like v1.0
, v2.5
, or beta-1
.
If you’re building software and want to version your work reliably, tags are an essential part of your Git workflow. In this guide, you’ll learn how to create, list, and push tags to a remote repository like GitHub.
✅ What Is a Git Tag?
A tag in Git is like a snapshot of your project at a specific commit. It’s often used to:
- Mark release points (e.g.,
v1.0.0
) - Sign important versions
- Make rollbacks easier
There are two main types of tags:
- Lightweight tags – like a simple bookmark
- Annotated tags – contain metadata (author, date, message, GPG signature)
🛠️ How to Create a Tag
1. Lightweight Tag
A simple reference to a commit:
git tag v1.0.0
This creates a tag named v1.0.0
pointing to the latest commit on your current branch.
2. Annotated Tag
More robust and recommended for public releases:
git tag -a v1.0.0 -m "Release version 1.0.0"
-a
: creates an annotated tag-m
: adds a message (like a commit message)
📌 Tagging a Specific Commit
If you want to tag a previous commit (not the latest one):
git tag -a v0.9.0 <commit-hash> -m "Tagging version 0.9.0"
You can find the commit hash with:
git log --oneline
🚀 Push Tags to GitHub
Tags are not automatically pushed to remotes, so you’ll need to push them explicitly.
Push a single tag:
git push origin v1.0.0
Push all tags:
git push origin --tags
🧹 Delete a Tag
Delete locally:
git tag -d v1.0.0
Delete from remote:
git push origin --delete tag v1.0.0
📃 List All Tags
git tag
To search/filter tags:
git tag -l "v1.*"
🔐 Signed Tags (Advanced)
To create a GPG-signed tag (useful for verifying authenticity):
git tag -s v1.0.0 -m "Signed release v1.0.0"
Make sure you’ve set up GPG keys before using signed tags.
🧠 Summary
Task | Command |
---|---|
Create lightweight tag | git tag v1.0.0 |
Create annotated tag | git tag -a v1.0.0 -m "Message" |
Tag a specific commit | git tag -a v1.0.0 <commit> |
Push a single tag | git push origin v1.0.0 |
Push all tags | git push origin --tags |
Delete a local tag | git tag -d v1.0.0 |
Delete a remote tag | git push origin --delete tag v1.0.0 |
List all tags | git tag |
🚀 Final Thoughts
Using tags in Git is a powerful way to mark milestones, manage releases, and keep your project organized. Whether you’re working solo or in a large team, tagging helps make your version history more meaningful and maintainable.