Git Tagging & Releases: Versioning Strategy

Git Tagging & Releases: Versioning Strategy
1. Lightweight vs. Annotated Tags
- Lightweight Tag: Just a pointer to a commit (No author info, no message).
git tag v1.0-beta - Annotated Tag (Recommended): A full Git object containing the tagger's name, email, date, and a message. Essential for professional software.
git tag -a v1.0.0 -m "First stable public release"
2. Semantic Versioning (SemVer)
To ensure your users aren't confused by version numbers, the industry uses the Major.Minor.Patch system.
- MAJOR (1.0.0 -> 2.0.0): Use this for "Breaking Changes." If you rewrite your API, you must bump the Major number.
- MINOR (1.1.0 -> 1.2.0): Use this for "New Features" that don't break old code.
- PATCH (1.1.1 -> 1.1.2): Use this for "Bug Fixes."
3. GitHub Releases: The Premium Layer
When you push a tag to GitHub (git push origin --tags), GitHub allows you to draft a Release on top of it.
- Release Notes: Automatically generate a list of every Pull Request merged since the last release.
- Binary Assets: Upload your
.exeor.zipfiles so users can download your tool without installing Git. - Automatic Archive: GitHub automatically creates a
.tar.gzand.zipof your source code for that specific version.
4. Professional Best Practice: Conventional Commits
Many teams automate their tagging using Conventional Commits. By writing commit messages like feat: add button or fix: fix alignment, a GitHub Action can automatically calculate the next SemVer number and create the tag for you. This is the gold standard for high-performance open-source libraries.
Frequently Asked Questions
Can I move a tag? Technically, yes, but it is Highly Discouraged. Tags are meant to be immutable. If you realize v1.0.0 was broken, don't move the tag—fix the code and release v1.0.1.
How do I delete a tag from GitHub?
You must delete it locally (git tag -d v1.0) and then push the deletion to the remote server (git push origin --delete v1.0).
Key Takeaway
Tagging is the bridge between "Development" and "Delivery." By mastering Semantic Versioning and the GitHub Release workflow, you transform from a developer who "Pushes Code" into a project maintainer who "Ships Product."
Read next: Git Submodules & External Libraries: Managing Dependencies →
Part of the GitHub Mastery Course — masters of the release.
