Skip to content

describe Git Command Guide

The git describe command generates a human-readable name for a given commit based on the most recent tag that precedes the commit. It provides a version-like string that includes the tag name, number of commits since the tag, and abbreviated commit hash.

Terminal window
git describe [options] [<commit-ish>]
OptionDescription
—allUse any ref found in refs/namespace
—tagsUse any tag found
—containsFind the tag that comes after the commit
—abbrev=Use digits to display SHA-1 (default 7, 0 to avoid)
—candidates=Consider up to candidates (default 10)
—exact-matchOnly output exact tag matches
—debugVerbose debugging output
—longAlways use long format (tag-NN-gSHA-abbrev)
—match Only consider tags matching given glob pattern
—exclude Do not consider tags matching given glob pattern
—alwaysShow unique abbreviated commit object as fallback
—first-parentFollow only the first parent commit upon seeing a merge commit
—brokenAllow looking at broken commits
—dirty[=]Append if repository is dirty (default “dirty”)
—brokenDescribe commits with broken files
—helpDisplay help
ParameterDescription
Commit to describe (default HEAD)
Terminal window
git describe

Shows tag-NN-gSHA description for current commit.

Terminal window
git describe HEAD~3

Describes commit 3 commits back from current HEAD.

Terminal window
git describe --all

Consider any ref in refs/namespace, not just tags.

Terminal window
git describe --tags

Use any tag found in refs/tags/ namespace.

Terminal window
git describe --long

Always use long format even for exact matches.

Terminal window
git describe --abbrev=4

Use 4 digits for SHA-1 abbreviation.

Terminal window
git describe --match "v[0-9]*"

Only consider tags matching v[0-9]* pattern.

Terminal window
git describe --contains HEAD~3

Find tag that contains the commit.

Terminal window
git describe --dirty=-modified

Append “-modified” if working directory has modifications.

Terminal window
git describe --exact-match

Only output if commit is exactly a tag.

Terminal window
git describe --first-parent

Follow only first parent in merge commits.

To describe the current commit, use:

Terminal window
git describe

How can I include all references in description?

Section titled “How can I include all references in description?”

To include all references in description, run:

Terminal window
git describe --all

To use only tags for description, execute:

Terminal window
git describe --tags

How can I find which tag contains a commit?

Section titled “How can I find which tag contains a commit?”

To find which tag contains a commit, use:

Terminal window
git describe --contains <commit>

To see if the repository is dirty, run:

Terminal window
git describe --dirty
  1. Generating version numbers for software releases
  2. Creating human-readable commit identifiers
  3. Finding the most recent tagged version from any commit
  4. Providing context for commits in automated systems
  5. Debugging by quickly identifying commit positions
  6. Supporting build systems that need version metadata