如何解释 git describe 输出

Bre*_*min 0 git

我在玩 git describe :

git branch
  branch1
* master

git tag tag1 HEAD~2

git tag tag2 HEAD

git describe --all HEAD~1
tags/tag1-1-gb772e8b

git rev-parse tag1
1ae346a3b91f5dbe4110ae143ce86825d79b82f3
Run Code Online (Sandbox Code Playgroud)

“tag1-1-gb772e8b”中的“1-gb772e8b”是什么意思?

nos*_*nos 6

tag1-1-gb772e8b
^    ^  ^ 
|    |  |
|    |  git hash of the commit  
|    |
|   number of commits after the tag 
|
|
Most recent tag
Run Code Online (Sandbox Code Playgroud)

这一切都与您提供给 git describe 的提交有关。在你的情况下它是 HEAD~1,所以

  • HEAD~1 有提交哈希 b772e8b
  • HEAD~1 是最近标签之后的 1 次提交
  • 早于 HEAD~1 的最新标签是 tag1

有关更深入的信息,请参阅文档,输出取决于是否有任何标签、存储库所处的状态以及您提供给的参数git describe

g哈希中还有一个,gb772e8b. 该文档描述为

“g”前缀代表“git”,用于根据管理软件的 SCM 描述软件的版本。