git rev-parse --short HEAD
outputs:
6aa3158a
git describe --tags --long
outputs:
2.3.4-rck1-0-g6aa3158a
I see that the latter command adds a g
to the commit hash. Why is this?
From man git-describe
:
The "g" prefix stands for "git" and is used to allow describing the version of a software depending on the SCM the software is managed with. This is useful in an environment where people may use different SCMs.
That is the documented behavior of --long
according to git-describe(1)
:
--long
Always output the long format (the tag, the number of commits and
the abbreviated commit name) even when it matches a tag. This is
useful when you want to see parts of the commit object name in
"describe" output, even when the commit in question happens to be a
tagged version. Instead of just emitting the tag name, it will
describe such a commit as v1.2-0-gdeadbee (0th commit since tag
v1.2 that points at object deadbee....).
And later on in the same document is an explanation for why it adds the g
prefix to the hash:
The "g" prefix stands for "git" and is used to allow describing the version of a software depending on the SCM the software is managed with. This is useful in an environment where people may use different SCMs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With