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.
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. |
# 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"
# Simple lightweight tag (no -a or -m flag):
$ git tag v1.0.0-beta
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"
# 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
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!
The global software engineering standard for tag naming is Semantic Versioning (MAJOR.MINOR.PATCH):
# 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
Strengthen your version control mastery by studying these connected classes:
Tag specific commit hashes across history with annotated semantic version tags.
Trigger automated builds and GitHub Releases on push of version tags (v*).
Inspect cryptographic tag objects signed with GPG and stored in .git/refs/tags.
Review all git tag creation, listing, pushing, and deletion commands.
Advance your software engineering skills with the next topic in our synchronized curriculum.
Continue to SSH Keys & GitHub → Previous: ← Tracking & Upstream | Full Syllabus