Class 24 of 50 • Remote Collaboration

Git Tagging: Lightweight vs Annotated Tags & Semantic Versioning (SemVer)

Branches in Git are moving targets that advance with every new commit. But when you deploy software to production (e.g. v1.0.0), you need a permanent, immutable bookmark anchored to that exact release snapshot. That is the purpose of Git Tags.

Lightweight vs Annotated Tags

Git supports two types of tags:

Tag Type Lightweight Tag Annotated Tag (Recommended)
Storage Model Just a simple pointer to a commit (stored as a ref file). Stored as a full object in the Git database with checksum.
Metadata Included Zero metadata. Only points to commit SHA. Tagger name, email address, date timestamp, and message.
GPG Signature Cannot be cryptographically signed. Can be signed and verified with GPG keys (-s).
Industry Best Practice Temporary personal bookmarks during local development. Formal production releases and official software distributions.

Creating Tags in Terminal

1. Creating an Annotated Tag (Recommended)

# Create annotated release tag with a message:
$ git tag -a v1.0.0 -m "Release version 1.0.0: Initial production release with auth & payments"

2. Creating a Lightweight Tag

# Simple lightweight tag (no -a or -m flag):
$ git tag v1.0.0-beta

3. Tagging an Older Historical Commit

You can tag any commit from the past by passing its commit hash:

$ git tag -a v0.9.0 9a1b2c4 -m "Tagged beta release candidate"

Listing and Inspecting Tags

# List all tags in alphabetical order:
$ git tag

# Search tags matching a pattern:
$ git tag -l "v1.8.*"

# Inspect tag metadata, author, and commit details:
$ git show v1.0.0

Pushing Tags to GitHub

By default, git push does NOT transfer tags to remote servers. You must explicitly push tags:

# Push a single specific tag to GitHub:
$ git push origin v1.0.0

# Push ALL local tags to GitHub simultaneously:
$ git push origin --tags

Pushing a tag to GitHub automatically creates an entry under the repository's Releases tab, allowing users to download source code .zip and .tar.gz archives!

Understanding Semantic Versioning (SemVer)

The global software engineering standard for tag naming is Semantic Versioning (MAJOR.MINOR.PATCH):

  • MAJOR (v2.0.0): Incompatible API changes, breaking architectural modifications.
  • MINOR (v1.1.0): Backwards-compatible new features and enhancements.
  • PATCH (v1.0.1): Backwards-compatible bug fixes and security patches.

Deleting Tags

# Delete a tag locally:
$ git tag -d v1.0.0

# Delete a tag on the remote GitHub repository:
$ git push origin --delete v1.0.0

Explore Related Git & GitHub Tutorials & Next Steps

Strengthen your version control mastery by studying these connected classes:

Commits & Atomic Snapshots

Tag specific commit hashes across history with annotated semantic version tags.

Automated Release Pipelines

Trigger automated builds and GitHub Releases on push of version tags (v*).

Annotated Tag Objects in .git

Inspect cryptographic tag objects signed with GPG and stored in .git/refs/tags.

Git CLI Command Reference

Review all git tag creation, listing, pushing, and deletion commands.

Frequently Asked Questions (FAQ) - Student & Interview Review

Yes, running `git checkout v1.0.0` or `git switch --detach v1.0.0` checks out the tagged commit. Because tags cannot move, you will be placed in a 'Detached HEAD' state.
A Git tag is a core Git version control marker pointing to a commit. A GitHub Release is a GitHub platform feature built on top of a Git tag that lets you attach binary assets (like compiled .exe, .dmg, or .apk files) and formatted release notes.
Yes! In Git's internal object model, a tag can theoretically point to a tree, blob, or even another tag object, though 99.9% of tags point to commits.

Next Step in Your Git & GitHub Learning Path:

Advance your software engineering skills with the next topic in our synchronized curriculum.

Continue to SSH Keys & GitHub → Previous: ← Tracking & Upstream | Full Syllabus

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Reddit

You may also like this!