Synopsis
git tag [-a] [-s] [-m <msg>] <name> [<commit>]
git tag -l ['<pattern>']
git tag -d <name>
Description
The git tag command marks specific commits with a memorable name, typically used for releases. There are two kinds of tags: lightweight (just a named pointer) and annotated (a full Git object with author, date, message, and optional GPG signature). For releases, always create annotated tags — they carry the metadata that release management requires.
Tags are NOT pushed by default. Use git push origin v1.2.3 to publish a single tag, or git push --tags for all of them. Once published, tags are normally immutable; rewriting a published tag breaks consumers and is strongly discouraged.
In day-to-day use, git tag integrates closely with shell aliases, editor plugins, and continuous integration. Power users often add aliases that combine flags they always pass, or wrap the command in scripts that enforce team conventions. Output formatting can be customized via Git config — pretty formats, color schemes, and pager behavior are all tunable. When something goes wrong, the first diagnostic step is usually to re-run the command with GIT_TRACE=1 in the environment, which reveals the underlying plumbing calls. For unusual situations, the --help output (git tag --help) opens the full manual page with details on every option, including those rarely used in casual workflows but essential for debugging or scripting at scale.
Understanding how git tag interacts with the rest of Git's data model — the object database, the index, refs, and the working tree — pays dividends. Each command operates on some subset of these pieces, and knowing which it touches helps predict outcomes and recover from mistakes. Reading the official Git documentation alongside hands-on practice in a throwaway repository is the fastest way to internalize the nuances. Most production issues with Git stem from one of three causes: surprising default behavior, partial network operations, or rewriting history that was already shared. A working mental model of git tag's side effects helps avoid all three.
Common Options
| Option | Description |
|---|---|
-a | Create an annotated tag. |
-s | Create a GPG-signed annotated tag. |
-m <msg> | Set the tag message. |
-l '<pattern>' | List tags matching a glob. |
-d <name> | Delete a local tag. |
-v <name> | Verify a signed tag. |
-f | Replace an existing tag (use with caution). |
--sort=<key> | Sort listing (e.g. -v:refname). |
Examples
git tag -a v1.0.0 -m "Release 1.0"
# Create an annotated tag at HEAD
git tag -s v1.0.1 -m "Patch release" abc123
# GPG-signed tag at a specific commit
git tag -l 'v1.*' --sort=-v:refname
# List 1.x tags newest first
git push origin v1.0.0
# Publish a tag
Common Mistakes
Creating a lightweight tag for a release loses metadata and signing. Use -a or -s. Forgetting git push --tags means colleagues never see your tag. Moving a tag with -f after publication confuses caches and CI systems.
Related Commands
git describe, git show, git push, git verify-tag