Tags mark important points in history, such as releases. In this lesson you will learn semantic versioning, create lightweight and annotated tags, push and delete them, check out a tagged version, and publish a GitHub Release.
📖 What You’ll Learn: what tags are and how they differ from branches, semantic versioning, lightweight vs annotated tags, creating, listing and inspecting tags, pushing and deleting tags, checking out a tag and detached HEAD, and GitHub Releases.
🏷️ What Is a Git Tag?
A tag is a permanent, human-friendly name for a specific commit, most often a release version such as v1.0.0. Unlike a branch, a tag does not move when new commits are added.
| Branch | Tag | |
|---|---|---|
| Moves with new commits | ✅ | ❌ Fixed to one commit |
| Purpose | Ongoing work | Marking a point in history (release, milestone) |
| Example | main, feature/login | v2.4.0, v2.4.1 |
🔢 Semantic Versioning (SemVer)
Most projects name tags with MAJOR.MINOR.PATCH:
| Part | Increase when | Example |
|---|---|---|
| MAJOR | You make incompatible (breaking) changes | v1.4.2 → v2.0.0 |
| MINOR | You add features in a backward-compatible way | v1.4.2 → v1.5.0 |
| PATCH | You make backward-compatible bug fixes | v1.4.2 → v1.4.3 |
Pre-releases add a suffix: v2.0.0-beta.1, v2.0.0-rc.1.
🔖 Lightweight vs Annotated Tags
| Lightweight | Annotated | |
|---|---|---|
| Command | git tag v1.0.0 | git tag -a v1.0.0 -m "Release 1.0.0" |
| Stores | Just a pointer to a commit | Tagger name, email, date and message |
| Can be signed | ❌ | ✅ (-s) |
| Recommended for | Private, temporary markers | Releases |
➕ Create Tags
git tag -a v1.0.0 -m "First stable release of the test framework" # tag the current commit
git tag -a v0.9.0 3f2a91c -m "Beta release" # tag an older commit
git tag v1.0.0-local # lightweight tag
📋 List and Inspect Tags
git tag # all tags, alphabetically
git tag -l "v1.*" # filter with a pattern
git show v1.0.0 # tag details plus the commit and its diff
git log --oneline --decorate # tags appear next to commits
tag v1.0.0
Tagger: Asha Verma <asha.verma@example.com>
Date: Thu Oct 30 12:05:10 2026 +0530
First stable release of the test framework
commit 8b1d4e2c7a9f0b1e2d3c4b5a69788f7e6d5c4b3a (tag: v1.0.0, main)
📤 Push Tags to GitHub
Tags are not pushed by a normal git push:
git push origin v1.0.0 # push one tag
git push origin --tags # push all local tags
git push --follow-tags # push commits and the annotated tags that point to them
🗑️ Delete or Move a Tag
git tag -d v1.0.0 # delete locally
git push origin --delete v1.0.0 # delete on GitHub
⚠️ Common mistake: Avoid changing a tag that others may already have fetched. Release tags should be immutable; if a release is broken, publish a new patch version (v1.0.1) instead of moving v1.0.0.
🔍 Check Out a Tag
git switch --detach v1.0.0 # look at the code as it was at v1.0.0
git switch -c hotfix/1.0.1 v1.0.0 # create a branch from the tag to fix it
Checking out a tag directly puts you in detached HEAD state: you are on a commit, not a branch. Create a branch if you want to commit.
🚀 Tags and GitHub Releases
On GitHub, a Release is built on a tag. It adds release notes, a title and downloadable files (binaries, reports, zip archives):
- Open the repository, click Releases, then Draft a new release.
- Choose an existing tag or create a new one (for example
v1.0.0). - Click Generate release notes to list merged pull requests automatically, edit them, and publish.
With the GitHub CLI: gh release create v1.0.0 --generate-notes. Tags can also trigger CI/CD, for example a workflow that runs on push: tags: ['v*'] to deploy a release (deploy with GitHub Actions).
📝 Assignment
- In
git-practice, create an annotated tagv0.1.0on the current commit and a lightweight tagcheckpoint. - Tag an older commit as
v0.0.1and list tags withgit tag -l "v0.*". - Push
v0.1.0to GitHub and find it under Tags; then push all tags. - Create a GitHub Release from
v0.1.0with generated release notes. - Delete
checkpointlocally and, if pushed, on GitHub. - Create a hotfix branch from
v0.1.0, commit a fix and tag itv0.1.1.
❓ FAQ
🤔 What is a tag in Git?
A fixed name for a specific commit, usually used to mark release versions such as v1.0.0.
🤔 What is the difference between a tag and a branch?
A branch moves forward as you commit; a tag always points to the same commit.
🤔 How do I push tags to GitHub?
git push origin <tag> for one tag or git push origin --tags for all of them. Normal git push does not send tags.
🤔 What is the difference between lightweight and annotated tags?
A lightweight tag is just a pointer. An annotated tag also stores the tagger, date and a message and can be signed, so it is recommended for releases.
🤔 How do I delete a remote tag?
git push origin --delete <tag>, and git tag -d <tag> for the local copy.
🎯 Next Steps
- 🔃 Pull Requests Step by Step
- 🌳 Branching Strategies: Git Flow, GitHub Flow and Trunk-Based
- 📘 Git and GitHub Tutorial: full course
🎬 Learn Git and GitHub step by step: watch the series on YouTube!
Subscribe to SqaToolsByDY • Practice on sqatools.in
2 thoughts on “Git Tags and Versioning: Create, Push and Delete Tags, and GitHub Releases”