How to Use Git Tags: A Complete Guide

Git tags are a powerful way to mark specific points in your project’s history, typically used to label version releases (e.g., v1.0.0). Unlike branches, tags are fixed references to a commit—they don’t change as you continue development.

In this guide, you’ll learn how to create, view, delete, and push tags in Git.


🏷️ What Is a Git Tag?

Tags are references to specific commits. Git supports two types:

  • Lightweight tags: Simple references to a commit (like a bookmark)
  • Annotated tags: Full objects in the Git database that include metadata like the tagger’s name, email, date, and message

✅ Step 1: Create a Tag

🔹 Lightweight Tag

git tag v1.0.0

Creates a tag pointing to the current commit.

🔹 Annotated Tag (Recommended for Releases)

git tag -a v1.0.0 -m "Release version 1.0.0"
  • -a creates an annotated tag
  • -m specifies a tag message

🔹 Tag a Specific Commit

git tag -a v1.0.0 9fceb02 -m "Tag specific commit"

Replace 9fceb02 with the commit hash.


✅ Step 2: List All Tags

git tag

To filter tags (e.g., starting with v1):

git tag -l "v1.*"

✅ Step 3: Push Tags to Remote

Tags are not pushed automatically. You must push them explicitly:

Push a single tag:

git push origin v1.0.0

Push all tags:

git push origin --tags

✅ Step 4: Delete a Tag

Delete local tag:

git tag -d v1.0.0

Delete tag from remote:

git push origin --delete tag v1.0.0

✅ Step 5: Checkout a Tag (Read-Only)

To view a tagged version (detached HEAD state):

git checkout v1.0.0

If you want to make changes, create a new branch from the tag:

git checkout -b new-feature v1.0.0

📝 Summary

ActionCommand
Create lightweight taggit tag v1.0.0
Create annotated taggit tag -a v1.0.0 -m "Message"
List tagsgit tag
Push a specific taggit push origin v1.0.0
Push all tagsgit push origin --tags
Delete local taggit tag -d v1.0.0
Delete remote taggit push origin --delete tag v1.0.0
Checkout tag (read-only)git checkout v1.0.0

🎯 Use Cases for Git Tags

  • Marking version releases (v1.0.0, v2.1.3)
  • Identifying important commits (e.g., milestones)
  • Automating CI/CD pipelines based on version tags
  • Managing changelogs and release notes

Git tags are essential for organizing releases and managing project milestones. Whether you’re shipping a new version or preparing for a rollback, tagging keeps your repository structured and version-aware.

Sharing Is Caring:

Leave a Comment