Tags in Git are used to mark specific points in history as important—usually to mark release versions (e.g., v1.0, v2.0). After creating tags locally, you need to push them to GitHub so others can see and use them.
This guide walks you through how to push tags to your GitHub repository effortlessly.
📌 What Are Git Tags?
- Tags are references to specific commits.
- Often used for releases or milestones.
- Two types:
- Lightweight tags: Simple pointers.
- Annotated tags: Full objects with metadata (recommended for releases).
✅ How to Push Tags to GitHub
1. Create a tag locally (if you haven’t already)
- Annotated tag:
git tag -a v1.0 -m "Release version 1.0"
- Lightweight tag:
git tag v1.0
2. Push a specific tag
git push origin <tag-name>
Example:
git push origin v1.0
3. Push all local tags at once
git push origin --tags
This pushes all tags that don’t exist on the remote yet.
🔎 Verify Tags on GitHub
Once pushed, you can see tags on GitHub:
- Go to your repo on GitHub.
- Click on “Tags” (usually under the Releases section).
- You’ll find your pushed tags listed there.
🧠 Bonus: Checkout and Use Tags
To check out a tag locally:
git checkout tags/<tag-name>
Example:
git checkout tags/v1.0
Note: This puts your repo in “detached HEAD” state, so avoid making changes unless you create a new branch.
🧩 Summary of Commands
Task | Command |
---|---|
Create annotated tag | git tag -a v1.0 -m "msg" |
Create lightweight tag | git tag v1.0 |
Push a single tag | git push origin v1.0 |
Push all tags | git push origin --tags |
List all tags | git tag |
Checkout a tag | git checkout tags/v1.0 |
📌 Final Thoughts
Pushing tags to GitHub is a great way to mark and share important points in your project’s history. Whether you’re releasing software versions or just tagging milestones, tags help keep your project organized and accessible.