Lesson 5 — Git Tags, Semantic Versioning, and GitHub Releases¶
1. Learning objectives¶
By the end of this lesson, you should understand:
- What Git tags are.
- The difference between lightweight and annotated tags.
- How Semantic Versioning works.
- How to create and manage tags.
- How to push tags to GitHub.
- How GitHub Releases work.
- How to write release notes.
- How to manage project versions.
2. What is a Git tag?¶
A Git tag is a reference identifying a specific commit.
Unlike a branch, which normally moves forward as new commits are added, a tag is intended to identify a fixed point in project history.
Example:
Here:
v1.0.0identifies commit C.v1.1.0identifies commit E.
Tags are useful for:
- Marking production releases.
- Identifying stable versions.
- Supporting deployments.
- Tracking bug-fix releases.
- Connecting source code to published software versions.
3. Lightweight vs annotated tags¶
Git supports two main types of tags.
Lightweight tags¶
A lightweight tag is essentially a named reference to a commit.
Create one:
List tags:
Inspect a tag:
Annotated tags¶
An annotated tag stores additional metadata:
- Tag name.
- Tagger.
- Date.
- Message.
- Target commit.
Create an annotated tag:
Inspect it:
Recommendation: Use annotated tags for official project releases.
4. Tag a specific commit¶
You don't have to tag only the latest commit.
Inspect history:
Example:
a81f912 docs: update installation guide
c92d145 feat: add authentication
b12a501 docs: add project overview
Tag a specific commit:
This associates v1.0.0 with commit b12a501.
5. Semantic Versioning (SemVer)¶
Semantic Versioning is a version-numbering convention.
Format:
Example:
| Component | Meaning | Example |
|---|---|---|
| MAJOR | Incompatible or breaking changes | 2.0.0 |
| MINOR | Backward-compatible functionality | 1.5.0 |
| PATCH | Backward-compatible bug fixes | 1.4.3 |
MAJOR version¶
Increase MAJOR when introducing incompatible changes.
Example: changing an API contract in a way that breaks existing clients.
MINOR version¶
Increase MINOR when adding functionality without breaking existing functionality.
Example: adding a new API endpoint while preserving existing endpoints.
PATCH version¶
Increase PATCH when fixing bugs without introducing incompatible changes.
Example: fixing an incorrect calculation without changing the public interface.
Pre-release versions¶
SemVer also supports pre-release identifiers:
Common meanings:
alpha: early development.beta: feature testing.rc: release candidate.
Pre-release versions are not necessarily ready for general production use.
6. List and inspect tags¶
List all tags:
List tags matching a pattern:
Show the latest reachable tag:
Show tags with their associated commits:
Inspect a tag:
Sort tags using version-aware sorting:
7. Push tags to GitHub¶
Creating a tag locally does not automatically publish it to GitHub.
Push one tag:
Push all local tags:
For normal release workflows, prefer pushing the specific release tag rather than publishing every local tag indiscriminately.
Check remote tags:
8. Delete a tag¶
Delete a local tag:
Delete a remote tag:
Be careful when deleting published release tags. Other developers and deployment systems may already depend on them.
9. Move or replace a tag¶
Sometimes a tag points to the wrong commit.
Inspect it:
If you intentionally need to replace a local tag:
Update the remote tag:
Warning: Replacing published tags changes the meaning of an existing version reference. Avoid doing this for official releases whenever possible. Publishing a new version is generally safer.
10. GitHub Releases¶
GitHub Releases provide a way to publish software versions based on Git tags.
A release can include:
- Version number.
- Release title.
- Release notes.
- Changelog.
- Downloadable assets.
- Pre-release designation.
- Latest-release designation.
A Git tag identifies a commit. A GitHub Release adds publication information around that version.
Create a GitHub Release¶
- Open your GitHub repository.
- Navigate to Releases.
- Select Draft a new release.
- Choose an existing tag or create a new one.
- Select the target branch or commit if creating a tag.
- Enter a release title.
- Write release notes.
- Add downloadable assets if needed.
- Publish the release.
11. Release notes¶
Release notes explain what changed in a particular version.
Example:
## Version 1.0.0
## Features
- Added repository setup documentation.
- Added branch management guide.
- Added commit conventions guide.
## Improvements
- Improved Git command examples.
- Organized training documentation.
## Documentation
- Added Git fundamentals.
- Added branch comparison instructions.
Good release notes should help users understand what changed without inspecting every commit.
Automatically generated release notes¶
GitHub can generate release notes from merged pull requests and associated contributors.
This is useful for projects with consistent PR titles, labels, and commit messages.
You can customize generated notes before publishing.
12. Recommended versioning strategy¶
For your future Django REST Framework and React projects, a versioning scheme could look like this:
| Version | Example milestone |
|---|---|
| 0.1.0 | Initial development version |
| 0.2.0 | Authentication implemented |
| 0.3.0 | Main business features implemented |
| 0.9.0 | Feature-complete testing version |
| 1.0.0 | First stable production release |
| 1.0.1 | Production bug fix |
| 1.1.0 | New backward-compatible functionality |
| 2.0.0 | Breaking API or architecture changes |
This is an example strategy, not a requirement. Define what constitutes a breaking change for each project.
13. Practical exercise — Publish your first release¶
We will create a release for the training repository.
Step 1 — Inspect the repository¶
Ensure your working tree is clean.
Step 2 — Inspect commit history¶
Review the history and identify a useful milestone.
Step 3 — Create a release preparation branch¶
Step 4 — Create a changelog¶
Create:
Add:
## Changelog
All notable changes to this project are documented here.
## [1.0.0] - 2026-11-03
### Added
- Initial GitHub training repository.
- Repository setup documentation.
- Git branching guide.
- Commit and history guide.
- Branch comparison guide.
### Documentation
- Added Module 1 lesson references.
- Added practical Git command examples.
Adjust the date if you publish the release on another day.
Step 5 — Commit the changelog¶
Step 6 — Push the release preparation branch¶
Open a pull request on GitHub:
- Base:
main - Compare:
chore/prepare-v1-release
Review and merge the pull request.
Synchronize your local main branch:
Delete the local branch:
Step 7 — Create an annotated tag¶
Inspect it:
Step 8 — Push the tag¶
Step 9 — Publish a GitHub Release¶
On GitHub:
- Open Releases.
- Select Draft a new release.
- Select
v1.0.0. - Enter the title
Version 1.0.0. - Add release notes.
- Publish the release.
Step 10 — Verify everything¶
Verify that the release is visible in the GitHub Releases section.
14. Important commands reference¶
| Command | Purpose |
|---|---|
git tag |
List local tags |
git tag v1.0.0 |
Create lightweight tag |
git tag -a v1.0.0 -m "message" |
Create annotated tag |
git tag -a TAG COMMIT -m "message" |
Tag a specific commit |
git show v1.0.0 |
Inspect a tag |
git tag -l "v1.*" |
Filter tags |
git describe --tags |
Describe current commit using tags |
git tag --sort=-version:refname |
Sort tags by version |
git push origin v1.0.0 |
Push one tag |
git push origin --tags |
Push all local tags |
git tag -d v1.0.0 |
Delete local tag |
git push origin --delete v1.0.0 |
Delete remote tag |
git ls-remote --tags origin |
Inspect remote tags |
15. Completion checklist¶
- [ ] Understand what Git tags are.
- [ ] Understand lightweight tags.
- [ ] Understand annotated tags.
- [ ] Understand Semantic Versioning.
- [ ] Create a tag.
- [ ] Tag a specific commit.
- [ ] Inspect tags.
- [ ] Push a tag to GitHub.
- [ ] Understand tag deletion.
- [ ] Understand GitHub Releases.
- [ ] Create a changelog.
- [ ] Publish a GitHub Release.
16. What comes next?¶
Lesson 6 covers GitHub repository collaboration and contribution guidance, including README improvements, LICENSE, CONTRIBUTING.md, CODE_OF_CONDUCT.md, and repository templates.
These files help establish professional standards for projects with multiple developers.