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
More on Commits, branches and tags
How do you write a good commit message?BeginnerWhat is the difference between `git add .`, `git add -A` and `git add -u`?BeginnerHow do you commit only part of the changes in a file?BeginnerHow do you change the last commit message or add a forgotten file?BeginnerWhat is the difference between `git switch`, `git restore` and `git checkout`?BeginnerWhat is the difference between lightweight and annotated tags?Beginner