Lesson Completion
Back to course

What Are Tags?

Beginner
7 minutes4.8Git

The Hook (The "Byte-Sized" Intro)

Branches move. Commits pile up. But sometimes you need to say: "This exact commit is version 1.0." That's a tag — a permanent bookmark in your Git history. Unlike branches, tags don't move when you make new commits. They stay fixed, pointing to the exact same commit forever. That's why every release, every deploy, every stable milestone uses a tag.

📖 What Are Tags?

A Git tag is a named reference that points to a specific commit. Unlike branches (which advance with each new commit), tags are fixed — they always point to the same commit.

Conceptual Clarity

Two types of tags:

TypeWhat It StoresUse Case
LightweightJust a name → commit pointerQuick local bookmarks
AnnotatedName + author + date + message + optional GPG signatureReleases, production milestones

Tags vs Branches:

FeatureTagBranch
Moves with new commits?❌ No — fixed forever✅ Yes — advances
Has metadata?Annotated: ✅❌ Just a pointer
PurposeMark a point in timeActive development
Examplev1.0.0, v2.3.1main, feature/login

Real-Life Analogy

If Git history is a book, branches are bookmarks that move as you read. Tags are like highlighted passages — they mark something important and stay exactly where they are, even as the book gets more pages.

Visual Architecture

gitGraph commit id: "A" commit id: "B" commit id: "C" tag: "v1.0.0" commit id: "D" commit id: "E" tag: "v1.1.0"

Why It Matters

  • Release tracking: Every software release should be tagged for traceability.
  • Deployment: CI/CD systems use tags to trigger production deployments.
  • Rollback: Tags make it trivial to return to a known-good version.
  • Communication: v2.1.0 is clearer than abc123def in team discussions.

Code

bash
# ─── Create a lightweight tag ─── git tag v1.0.0 # Points to current HEAD # ─── Create an annotated tag (recommended for releases) ─── git tag -a v1.0.0 -m "First stable release" # Stores: tagger name, email, date, message # ─── Tag a specific commit ─── git tag -a v0.9.0 abc1234 -m "Beta release" # ─── View a tag's details ─── git show v1.0.0 # For annotated: shows tagger, date, message + commit diff # For lightweight: shows only the commit # ─── List all tags ─── git tag

Key Takeaways

  • Tags are fixed pointers to commits — they don't move like branches.
  • Annotated tags store metadata (author, date, message) — use these for releases.
  • Lightweight tags are just named pointers — use for local bookmarks.
  • Every release, deployment, and milestone should have a tag.

Interview Prep

  • Q: What is the difference between a lightweight and an annotated tag? A: A lightweight tag is just a name pointing to a commit — no metadata. An annotated tag is a full Git object storing the tagger's name, email, date, and a message. Annotated tags are recommended for releases because they provide context and can be GPG-signed.

  • Q: How are tags different from branches? A: Branches are movable pointers that advance with each new commit. Tags are fixed pointers that always reference the same commit. Branches are for ongoing work; tags are for marking specific milestones.

  • Q: Why should releases be tagged? A: Tags provide a human-readable, permanent reference to a specific commit. They enable rollbacks to known-good versions, trigger CI/CD pipelines, and make version tracking and communication clear across the team.

Topics Covered

Git TagsGit Fundamentals

Tags

#git#tags#releases#beginner-friendly

Last Updated

2026-02-13