git_tagging
git tagging
Create and manage version tags.
π·οΈ Creating Tags
Lightweight Tag
git tag v1.0.0
Creates simple tag pointing to current commit.
Annotated Tag (Recommended)
git tag -a v1.0.0 -m "Release version 1.0.0"
Creates tag with message, author, and date information.
Tag Specific Commit
git tag -a v1.0.0 abc1234 -m "Release version 1.0.0"
Creates tag on a specific commit hash.
Signed Tag
git tag -s v1.0.0 -m "Signed release"
Creates GPG-signed tag.
π View Tags
List All Tags
git tag
Shows all tags in repository.
List Tags with Pattern
git tag -l "v1.*"
Lists tags matching pattern.
Show Tag Details
git show v1.0.0
Shows tag information and associated commit.
List Tags with Messages
git tag -n
Lists tags with first line of message.
List with Full Messages
git tag -n99
Lists tags with up to 99 lines of message.
π Tag Types
graph TD
A[Git Tags] --> B[Lightweight]
A --> C[Annotated]
B --> D[Just a pointer to commit]
C --> E[Full Git object with metadata]
C --> F[Recommended for releases]
β¬οΈ Sharing Tags
Push Single Tag
git push origin v1.0.0
Pushes specific tag to remote.
Push All Tags
git push origin --tags
Pushes all local tags to remote.
Push Only Annotated Tags
git push origin --follow-tags
Pushes commits and annotated tags only.
β Checkout Tags
Checkout Tag (Detached HEAD)
git checkout v1.0.0
Switches to tag. Warning: detached HEAD state.
Create Branch from Tag
git checkout -b release-1.0 v1.0.0
Creates new branch starting from tag.
ποΈ Deleting Tags
Delete Local Tag
git tag -d v1.0.0
Removes tag from local repository.
Delete Remote Tag
git push origin --delete v1.0.0
Removes tag from remote repository.
Alternative Remote Delete
git push origin :refs/tags/v1.0.0
Alternative syntax to delete remote tag.
π Fetch Remote Tags
Fetch All Tags
git fetch --tags
Downloads all tags from remote.
Fetch and Prune Tags
git fetch --prune --prune-tags
Fetches and removes locally deleted remote tags.
βοΈ Semantic Versioning
Format: MAJOR.MINOR.PATCH
| Change | Version | When |
|---|---|---|
| Major | v2.0.0 | Breaking changes |
| Minor | v1.1.0 | New features (backwards compatible) |
| Patch | v1.0.1 | Bug fixes |
Pre-release Tags
git tag -a v2.0.0-beta.1 -m "Beta release"
Creates pre-release version tag.
Release Candidate
git tag -a v2.0.0-rc.1 -m "Release candidate 1"
Creates release candidate tag.
π‘ Tips
git tag --contains abc1234
git describe --tags --abbrev=0
git describe --tags
Shows: v1.0.0-5-gabc1234 (5 commits after v1.0.0)
π Related
#git #tag #version #release #advanced