How to tag a release in Git
· Category: Git
Short answer
Use git tag to mark specific commits as important, typically for version releases.
Steps
- Create a lightweight tag:
git tag v1.0.0
- Create an annotated tag:
git tag -a v1.0.0 -m "Release version 1.0.0"
- Push tags to remote:
git push origin --tags
- Delete a local tag:
git tag -d v1.0.0
Tips
- Use semantic versioning (MAJOR.MINOR.PATCH) for clarity.
- Annotated tags include metadata like author and date; prefer them for releases.
- Tags do not move; they permanently mark a commit.
Common issues
- Forgetting to push tags: they are not sent to remotes by default.
- Tagging the wrong commit: move a tag with
-for delete and recreate.