Git and GitHub course menu
Git Tags: Mark Releases with git tag
Mark versions with lightweight and annotated Git tags, list and inspect them, tag old commits, push tags to GitHub, use semantic versioning, and create GitHub Releases.
On this page
A tag is a permanent name for one commit. Where a branch moves forward with each commit, a tag stays put. Tags are mainly used to mark releases, such as v1.0.0.
Create a tag#
An annotated tag stores a message, the tagger and the date. Use this kind for releases:
git tag -a v1.0.0 -m "First public release"
git tagv1.0.0A lightweight tag is only a name for a commit, with no extra data:
git tag trial-build
git tag -ltrial-build
v1.0.0Tag an older commit#
Give a commit ID or a reference:
git tag -a v0.9.0 HEAD~1 -m "Beta release"
git log --oneline --decorate0225af6 (HEAD -> main, tag: v1.0.0, tag: trial-build) Add search
94c4f4f (tag: v0.9.0) Add login
fbbd872 First versionInspect a tag#
git show v1.0.0 --no-patchtag v1.0.0
Tagger: Asha Rao <[email protected]>
Date: Thu Nov 5 09:15:00 2026 +0530
First public release
commit 0225af684eac8829b80fd45b5df95e1651ead8a4
Author: Asha Rao <[email protected]>
Date: Thu Nov 5 09:10:00 2026 +0530
Add searchFilter and delete#
git tag -l "v1.*"
git tag -d trial-build
git tagv1.0.0
Deleted tag 'trial-build' (was 0225af6)
v0.9.0
v1.0.0Push tags to GitHub#
git push does not send tags by default. Push them separately:
git push origin v1.0.0 # one tag
git push origin --tags # all tagsDelete a tag from GitHub with:
git push origin --delete v1.0.0Go back to a tagged version#
You can look at the code as it was at a tag. This puts you in a state called detached HEAD: you are on a commit rather than a branch.
git switch --detach v0.9.0
cat app.txtHEAD is now at 94c4f4f Add login
v1
loginNew commits made here do not belong to any branch. To work from this point, create a branch with git switch -c hotfix. To go back, switch to a branch:
git switch -q main
git branch --show-currentmainSemantic versioning#
Most projects number releases as MAJOR.MINOR.PATCH:
GitHub Releases#
A Release on GitHub is a page built around a tag, with notes and optional downloadable files. On your repository's page, open Releases, then Draft a new release, choose a tag, and write what changed. GitHub can generate the notes from your merged pull requests.
Common mistakes#
Practice#
Key takeaway#
Next: Pushing a Project to GitHub.
Finished this lesson?