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:

PartGoes up whenExample
PATCHA bug is fixed, nothing else changes1.2.0 → 1.2.1
MINORA feature is added, and old code still works1.2.1 → 1.3.0
MAJORSomething breaks for existing users1.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

LightweightAnnotated
Made withgit tag v1.0.0git tag -a v1.0.0 -m "…"
StoresJust a name for a commitA name, the tagger, a date and a message
Use forPrivate bookmarksReleases

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

Terminal
git switch main
git pull
git tag -a v1.1.0 -m "Release 1.1.0"
git show v1.1.0
Output
tag 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:

Terminal
git push origin v1.1.0
Output
To github.com:jknithin36/git-learning.git
 * [new tag]         v1.1.0 -> v1.1.0

git 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

Terminal
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 was

git 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

Terminal
git tag -d v1.1.0                  # delete it locally
git push origin --delete v1.1.0    # and on GitHub

Only 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:

Terminal
gh release create v1.1.0 --generate-notes

Quick reference

TaskCommand
Create an annotated taggit tag -a v1.2.0 -m "…"
Push one taggit push origin v1.2.0
Push a branch and its tagsgit push --follow-tags
List tagsgit tag
Show a taggit show v1.2.0
Delete a tag locallygit tag -d v1.2.0
Delete a tag on GitHubgit push origin --delete v1.2.0
Publish a releasegh release create v1.2.0 --generate-notes