git rev-parse --short HEAD
会输出:
6aa3158a
git describe --tags --long
的输出结果为:
2.3.4-rck1-0-g6aa3158a
我发现后面的命令在提交哈希值后添加了一个
g
。这是为什么?git rev-parse --short HEAD
会输出:
6aa3158a
git describe --tags --long
的输出结果为:
2.3.4-rck1-0-g6aa3158a
g
。这是为什么?从git-describe 的手册
中翻译得到:
"g"前缀表示"git",用于描述软件的版本,具体取决于软件所使用的SCM。这在人们使用不同SCM的环境中非常有用。
根据 git-describe(1)
的文档,--long
的行为如下:
--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....).
在同一份文件中稍后解释了为什么要将g
前缀添加到哈希值中:
"g"前缀代表"git",用于描述软件版本取决于软件所使用的SCM。这在人们可能使用不同SCM的环境中非常有用。