Git and GitHub · Part 3 · GitHub and remote repositories
Releases and tags
Naming a moment in history
“The version from last Tuesday” is hard to find. v1.2.0 isn't. A tag is a permanent name for one commit, usually a version that was shipped. Unlike a branch, it never moves. A release is GitHub's page around a tag: notes on what changed, and files to download.
Semantic versioning
Most projects number versions as MAJOR.MINOR.PATCH, a scheme called semantic versioning (SemVer). Each part says what kind of change it is:
| Part | Goes up when | Example |
|---|---|---|
| PATCH | A bug is fixed, nothing else changes | 1.2.0 → 1.2.1 |
| MINOR | A feature is added, and old code still works | 1.2.1 → 1.3.0 |
| MAJOR | Something breaks for existing users | 1.3.0 → 2.0.0 |
Raising one part resets the ones after it to zero. Versions below 1.0.0 mean “still unstable, anything may change”. A pre-release adds a label: 2.0.0-beta.1. The v in v1.2.0 is only a naming habit for tags.
Two kinds of tags
| Lightweight | Annotated | |
|---|---|---|
| Made with | git tag v1.0.0 | git tag -a v1.0.0 -m "…" |
| Stores | Just a name for a commit | A name, the tagger, a date and a message |
| Use for | Private bookmarks | Releases |
Use annotated tags for versions. Tools like git describe and --follow-tags look for them, and they record who tagged the release and when.
Tagging a version
1.Create the tag
git switch main
git pull
git tag -a v1.1.0 -m "Release 1.1.0"
git show v1.1.0tag v1.1.0
Tagger: Nithin <you@example.com>
Date: Mon Nov 23 12:00:00 2026 -0500
Release 1.1.0
commit 4253151…To tag an older commit, add its hash: git tag -a v0.9.0 a1b2c3d -m "Release 0.9.0".
2.Push it
git push doesn't send tags. Push one by name:
git push origin v1.1.0To github.com:jknithin36/git-learning.git
* [new tag] v1.1.0 -> v1.1.0git push --follow-tags pushes the branch along with any annotated tags on its new commits. git push --tags pushes every tag, including old experiments, so it's best avoided.
3.List and use tags
git tag # every tag
git tag -l "v1.*" # only 1.x
git describe --tags # the nearest tag to HEAD
git switch --detach v1.1.0 # look at the code as it wasgit describe --tags printed v1.1.0-1-gd28e4d9: one commit after v1.1.0, at commit d28e4d9. Switching to a tag gives a detached HEAD (Lesson 9); git switch main goes back.
4.Fix a wrong tag
git tag -d v1.1.0 # delete it locally
git push origin --delete v1.1.0 # and on GitHubOnly do that before anyone uses the version. Once people have downloaded it, leave it and release v1.1.1: a tag that changes meaning breaks trust, as rewriting shared history does.
Releases on GitHub
On the repository page, click Releases, then Draft a new release. Choose the tag (or type a new one to create it), and click Generate release notes: GitHub lists every merged pull request since the last release, with its author. Edit the notes, attach files if there are any, and click Publish release.
Ticking Set as a pre-release marks betas, so GitHub doesn't show them as the latest version. From the terminal:
gh release create v1.1.0 --generate-notesQuick reference
| Task | Command |
|---|---|
| Create an annotated tag | git tag -a v1.2.0 -m "…" |
| Push one tag | git push origin v1.2.0 |
| Push a branch and its tags | git push --follow-tags |
| List tags | git tag |
| Show a tag | git show v1.2.0 |
| Delete a tag locally | git tag -d v1.2.0 |
| Delete a tag on GitHub | git push origin --delete v1.2.0 |
| Publish a release | gh release create v1.2.0 --generate-notes |