Git tags are reference points in a repository's history that mark specific commits, typically used to highlight software releases, version milestones, or significant project stages. Unlike branches, tags are static and do not change over time.
Tag Type |
Description |
Use Case |
Lightweight Tags |
Simple named references |
Quick, temporary marking |
Annotated Tags |
Contain metadata and signing |
Formal release versioning |
Tag Creation Workflow
graph TD
A[Commit Code] --> B{Select Commit}
B --> |Lightweight Tag| C[git tag v1.0]
B --> |Annotated Tag| D[git tag -a v1.0 -m "Release version"]
Code Examples
Creating a Lightweight Tag
## Tag current commit
git tag v1.0
## Tag specific commit
git tag v1.0 <commit-hash>
Creating an Annotated Tag
## Create annotated tag with message
git tag -a v1.0 -m "First stable release"
## Create signed tag with GPG
git tag -s v1.0 -m "Signed release"
Tag Use Cases in Version Control
Git tags are crucial for:
- Marking software releases
- Creating stable reference points
- Facilitating version management
- Enabling reproducible builds