I am experimenting with git describe as we want to use this in our CI system. However, I am not getting the expected results and neither the git describe documentation nor googling nor stackoverflow have helped me understand why.
The repository ==============
git log --oneline --graph
* 9a45651 (HEAD -> main) m c7 * b7982a9 merged r3 |\ | * 8c2adbe (tag: v3.0.0) r3 c1 |/ * 273a50e m c6 * 6014487 merged r2 |\ | * aa906b8 (tag: v2.0.0) r2 c2 | * 716c189 r2 c1 |/ * f0e2c71 m c5 * d42bc37 m c4 * 9060516 merged r1 |\ | * 619d331 (tag: v1.0.0) r1 c2 | * 75f90de r1 c1 * | 372f1fe m c3 |/ * a27d5e4 m c2 * a66cb53 m c1
Expected result ===============
When running git describe on main I'd expect v3.0.0-x-d???????
Actual result =============
What I am getting instead is v2.0.0-13-g9a45651
More information ================
git describe --debug ---------------------
# git describe --debug
describe HEAD
No exact match on refs or tags, searching to describe
annotated 13 v2.0.0
annotated 13 v1.0.0
annotated 14 v3.0.0
traversed 15 commits
v2.0.0-13-g9a45651amount of commits between tag and HEAD --------------------------------------
$ git log --oneline v2.0.0..HEAD | wc -l
5 $ git log --oneline v3.0.0..HEAD | wc -l
2git version -----------
I have tested 2.36.1 and 2.37.0 both on Ubuntu 20.04.4 LTS both installed from # deb-src http://ppa.launchpad.net/git-core/ppa/ubuntu focal main
Script to recreate the repository ---------------------------------
https://gist.github.com/twigs/bb0cbe29af55b8141c19d25de47e0eed