Version Strings With git describe
Build a version like v1.2-5-gabc123 for build metadata.
Run git describe --tags --always --dirty to print the nearest tag plus commit distance.
01Command
Command
$ git describe --tags --always --dirty02What it does
describe turns a commit into a sortable, human-readable identifier that tells you how far past a release you are and whether the tree is dirty. It is a common input to build scripts and --version output, which is exactly the kind of metadata a terminal pipeline provides.
03Risk
!Warning: Repositories without tags fall back to a short SHA; tag releases consistently for meaningful output.
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- git-describe documentationEvidence: Documents git describe, which names a commit from the nearest tag.
Last verified: 2026-10-13 · Category: Developer