bashbeginner

Git Tag Management for Releases

Create, list, push, and manage annotated and lightweight tags for version releases.

bash
# Create lightweight tag
git tag v1.0.0

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

# Tag a specific commit
git tag -a v1.0.0 abc1234 -m "Release version 1.0.0"

# List all tags
git tag

# List tags matching a pattern
git tag -l "v1.*"

# Show tag details
git show v1.0.0

# Push a specific tag
git push origin v1.0.0

# Push all tags
git push origin --tags

# Delete local tag
git tag -d v1.0.0

# Delete remote tag
git push origin --delete v1.0.0

# Checkout a tag (detached HEAD)
git checkout v1.0.0

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

# Sort tags by version (semver)
git tag -l --sort=-v:refname "v*"

# Show latest tag
git describe --tags --abbrev=0

# Show distance from latest tag
git describe --tags

Use Cases

  • Marking release points in project history
  • Triggering CI/CD deployments from tags
  • Managing semantic versioning workflow

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.