bashintermediate

Git Tags — Signed Releases and Versioning

Create signed and annotated tags for releases with GPG verification and semantic versioning.

bash
# Create annotated tag (recommended for releases)
git tag -a v1.2.0 -m "Release 1.2.0: auth improvements"

# Create signed tag (requires GPG key)
git tag -s v1.2.0 -m "Release 1.2.0: auth improvements"

# Tag a specific past commit
git tag -a v1.1.1 abc1234 -m "Hotfix: XSS patch"

# List tags with details
git tag -l -n1                  # one-line annotation
git tag -l 'v1.*'               # filter by pattern

# Push tags to remote
git push origin v1.2.0          # push specific tag
git push origin --tags          # push all tags
git push --follow-tags          # push commits + annotated tags

# Verify a signed tag
git tag -v v1.2.0

# Delete a tag
git tag -d v1.1.0               # local
git push origin --delete v1.1.0 # remote

# Show tag details
git show v1.2.0

# Get latest tag on current branch
git describe --tags --abbrev=0

# Commits since last tag
git log $(git describe --tags --abbrev=0)..HEAD --oneline

# Configure GPG for signing
git config --global user.signingkey YOUR_KEY_ID
git config --global tag.gpgSign true     # auto-sign tags
git config --global commit.gpgSign true  # auto-sign commits

Use Cases

  • Creating verified release tags
  • Semantic versioning for packages
  • Generating changelogs between release tags

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.