Skip to main content
Back to command reference
Tagging & Releases

git describe

Generate a human-readable name for the current commit

Practical example

bash
git describe --tags
# v1.0.0-5-gabc1234 (5 commits after v1.0.0, hash abc1234)
git describe --dirty
# v1.0.0-dirty (uncommitted changes exist)

Command overview & how it works

Produces a string that combines the nearest annotated tag, the number of commits since that tag, and the abbreviated commit hash — for example, v1.0.0-5-gabc1234. This is the standard command for generating version strings in build systems and release artifacts. The format breaks down as: the closest tag name (v1.0.0), the number of additional commits since that tag (5), and the abbreviated commit hash prefixed with 'g' (gabc1234). Use git describe --tags to also consider lightweight tags, git describe --always to always show a result even without any tags, and git describe --dirty to append '-dirty' if the working directory has uncommitted changes. Many CI/CD pipelines use this command to embed version information into compiled binaries.

Chapter 05 · Remotes & Collaboration

Master upstream tracking, SSH auth, and team workflows

Upstream sync strategies, merge vs rebase on pull, and semantic release tagging in the 97-page course — ₹499.

Learn more

Practical tips

  • Embed git describe --tags --always into build scripts to stamp binaries with a human-readable version.
  • Add --dirty so uncommitted changes are reflected in the version string.
  • The format <nearest-tag>-<commits-since>-g<hash> tells you exactly which commit a build came from.

Deep-dive guides & tutorials

In-depth walkthroughs and practical scenarios related to git describe

All guides →

Related commands

More from Tagging & Releases