Interview Prep/Git & GitHub/Commits, branches and tags

How does `git describe` work and where is it useful?

IntermediateConceptCommits, branches and tags
Answer

It finds the nearest reachable annotated tag and prints <tag>-<commits-since>-g<short-sha>, such as v1.4.0-12-g3fa9c21. CI uses it to stamp build versions that are traceable to an exact commit. Add --tags to include lightweight tags and --dirty to flag uncommitted changes.

git describe --tags --always --dirty
All Git & GitHub questions Roadmap: Git & GitHub

More on Commits, branches and tags