Terminal GuideTerminal Guide

git tag Command Guide

Create, list, delete or verify a tag object signed with GPG

6 min readLast updated: January 19, 2026
Dai Aoki

Dai Aoki

CEO at init, Inc. / CTO at US & JP startups / Creator of WebTerm

Quick Reference

Create

git tag <name>Lightweight tag
git tag -a <name> -m "msg"Annotated tag
git tag <name> <commit>Tag specific commit

List/Show

git tagList all tags
git tag -l "v1.*"Filter tags
git show <tag>Show tag details

Remote

git push origin <tag>Push single tag
git push --tagsPush all tags
git push origin --delete <tag>Delete remote tag

Downloadable Image Preview

Failed to generate preview

Basic Usage

The git tag command creates, lists, and deletes tags. Tags mark specific points in history, typically used for releases.

bash
# Create a lightweight tag
git tag v1.0.0

# Create an annotated tag (recommended)
git tag -a v1.0.0 -m "Release version 1.0.0"

# List all tags
git tag

Annotated vs Lightweight Tags

Annotated (-a)

  • • Stores tagger name, email, date
  • • Has a tagging message
  • • Can be GPG signed
  • • Recommended for releases

Lightweight

  • • Just a pointer to commit
  • • No extra metadata
  • • Cannot be signed
  • • Good for temporary markers
bash
# Annotated tag (full metadata)
git tag -a v1.0.0 -m "First stable release"

# View annotated tag info
git show v1.0.0
# Shows: tagger, date, message, and commit

# Lightweight tag (just a pointer)
git tag v1.0.0-light

# View lightweight tag
git show v1.0.0-light
# Shows: only the commit info
Tip
Use annotated tags for releases and milestones. They provide an audit trail with who tagged and when.

Listing and Filtering Tags

bash
# List all tags
git tag

# List with pattern matching
git tag -l "v1.*"
git tag -l "release-*"

# Sort by version (semantic versioning)
git tag -l --sort=-version:refname

# Show tag with commit info
git tag -n
git tag -n1  # Show first line of message

# Find which tag contains a commit
git tag --contains abc1234

Pushing Tags to Remote

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

bash
# Push a single tag
git push origin v1.0.0

# Push all tags
git push --tags

# Push only annotated tags (recommended)
git push --follow-tags

# Fetch tags from remote
git fetch --tags
Warning
Be careful with git push --tags as it pushes ALL local tags. Prefer pushing specific tags or use --follow-tags.

Deleting Tags

bash
# Delete local tag
git tag -d v1.0.0

# Delete remote tag
git push origin --delete v1.0.0
git push origin :refs/tags/v1.0.0  # Alternative syntax

# Delete and recreate (move tag)
git tag -d v1.0.0
git tag v1.0.0 <new-commit>
git push origin -f v1.0.0

Practical Examples

bash
# Release workflow
git checkout main
git pull
git tag -a v2.0.0 -m "Version 2.0.0 - New features"
git push origin v2.0.0

# Tag a past commit
git log --oneline
git tag -a v0.9.0 abc1234 -m "Tagging old release"

# Checkout a specific tag
git checkout v1.0.0
# Note: This puts you in detached HEAD state

# Create branch from tag
git checkout -b hotfix-v1 v1.0.0

# Compare tags
git diff v1.0.0 v2.0.0
git log v1.0.0..v2.0.0 --oneline

# GPG signed tag
git tag -s v1.0.0 -m "Signed release"
git tag -v v1.0.0  # Verify signature
OptionDescription
-aCreate annotated tag
-m <msg>Tag message
-dDelete tag
-l <pattern>List tags matching pattern
-sCreate GPG-signed tag

Frequently Asked Questions

What is the difference between annotated and lightweight tags?

Annotated tags (-a) store metadata like tagger name, date, and message. Lightweight tags are just pointers to commits. Use annotated tags for releases.

How do I tag a past commit?

Use "git tag <tagname> <commit-hash>" to tag any commit. Find the commit hash with git log first.

Why don't my tags appear on the remote?

Tags are not pushed by default. Use "git push origin <tagname>" or "git push --tags" to push tags to the remote.

How do I rename a tag?

Git doesn't support renaming tags directly. Create a new tag pointing to the same commit, then delete the old tag.

Summary

git tag marks important points in your repository history. Use annotated tags for releases and remember to push tags explicitly.

Quick Reference

  • git tag -a v1.0 -m "msg" - Annotated tag
  • git tag -l "v1.*" - List matching tags
  • git push origin <tag> - Push tag
  • git tag -d <tag> - Delete local tag

Official Documentation

For authoritative information, refer to the official documentation:

Related Articles