Skip to content

🏷️ Chapter 14: Tag Management — Bookmarking History

Lightweight Tags vs Annotated Tags

Tags are like bookmarks — giving a specific commit a memorable name, typically used to mark version numbers.

ComparisonLightweight TagsAnnotated Tags
NatureJust a pointer to a commitAn independent Git object
Contains infoOnly the tag nameTag name, author, date, message
Use caseTemporary markingOfficial releases (recommended)
Commandgit tag v1.0git tag -a v1.0 -m "..."

Tag Operations

bash
# Create an annotated tag (recommended!)
git tag -a v1.0.0 -m "🎉 First official release"

# Create a lightweight tag
git tag v1.0-beta

# Tag a historical commit
git tag -a v0.1.0 a1b2c3d -m "Marking the first commit"

# View all tags
git tag
v0.1.0
v1.0-beta
v1.0.0

# Search tags by pattern
git tag -l "v1.*"
v1.0-beta
v1.0.0

# View tag details
git show v1.0.0
tag v1.0.0
Tagger: Your Name <your.email@example.com>
Date:   Thu Jun 20 18:00:00 2025 +0800

🎉 First official release

commit f4e5d6c7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3 (HEAD -> main, tag: v1.0.0)
Author: Your Name <your.email@example.com>
Date:   Thu Jun 20 10:30:00 2025 +0800

    feat: add welcome message

# Push a tag to remote
git push origin v1.0.0

# Push all tags
git push origin --tags

# Delete a local tag
git tag -d v1.0-beta

# Delete a remote tag
git push origin --delete v1.0-beta