Progress:
TIER 1 · MODULE 28· Basics

git describe

Outputs a human-readable version string from the nearest tag.

🎯 What & why

Produce a human-readable name for any commit relative to the nearest reachable tag. Output: v1.2-7-g<sha> means '7 commits past v1.2, current commit <sha>'.

🧠 Mental model

Describe walks history backward from a commit until it finds a tag, then formats <tag>-<count>-g<short-sha>. With --always, it falls back to a bare short SHA if no tag is reachable.

🛠️ Synopsis

git describe [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]
git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>] --broken[=<mark>]

🎚️ Switches & options

FlagWhat it does
--tagsUse any tag, not just annotated.
--alwaysFall back to short SHA if no tag is reachable.
--abbrev=<n>Length of the short SHA component.
--dirty[=<suffix>]Append -dirty (or chosen suffix) if working tree has changes.
--match <pattern>Only consider tags matching <pattern> (e.g. v[0-9]*).

💡 Use cases

🧪 Examples

Describe the current commit.
$ git describe
v1.2-7-g2a3b4c5
Describe with dirty marker.
$ git describe --dirty
v1.2-7-g2a3b4c5-dirty
Use only release-style tags.
$ git describe --match 'v[0-9]*'

🎓 Recommendations

🪤 Common pitfalls

🔗 Related modules

📝 Quiz

Hit each option, then Check answers. Score is recorded; Next is always open.