Git Tags and Versioning: Create, Push and Delete Tags, and GitHub Releases

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.

Advertisement

📖 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.

BranchTag
Moves with new commits✅❌ Fixed to one commit
PurposeOngoing workMarking a point in history (release, milestone)
Examplemain, feature/loginv2.4.0, v2.4.1

🔢 Semantic Versioning (SemVer)

Most projects name tags with MAJOR.MINOR.PATCH:

PartIncrease whenExample
MAJORYou make incompatible (breaking) changesv1.4.2 → v2.0.0
MINORYou add features in a backward-compatible wayv1.4.2 → v1.5.0
PATCHYou make backward-compatible bug fixesv1.4.2 → v1.4.3

Pre-releases add a suffix: v2.0.0-beta.1, v2.0.0-rc.1.


🔖 Lightweight vs Annotated Tags

LightweightAnnotated
Commandgit tag v1.0.0git tag -a v1.0.0 -m "Release 1.0.0"
StoresJust a pointer to a commitTagger name, email, date and message
Can be signed❌✅ (-s)
Recommended forPrivate, temporary markersReleases

➕ 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):

  1. Open the repository, click Releases, then Draft a new release.
  2. Choose an existing tag or create a new one (for example v1.0.0).
  3. 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

  1. In git-practice, create an annotated tag v0.1.0 on the current commit and a lightweight tag checkpoint.
  2. Tag an older commit as v0.0.1 and list tags with git tag -l "v0.*".
  3. Push v0.1.0 to GitHub and find it under Tags; then push all tags.
  4. Create a GitHub Release from v0.1.0 with generated release notes.
  5. Delete checkpoint locally and, if pushed, on GitHub.
  6. Create a hotfix branch from v0.1.0, commit a fix and tag it v0.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

🎬 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”

Leave a Comment