代码之家  ›  专栏  ›  技术社区  ›  basickarl

git descripe--标记--long将字符添加到哈希?[副本]

git
  •  8
  • basickarl  · 技术社区  · 9 年前

    git rev-parse --short HEAD 输出:

    6aa3158a
    

    git describe --tags --long 输出:

    2.3.4-rck1-0-g6aa3158a
    

    我看到后一个命令添加了一个 g 提交哈希。为什么会这样?

    2 回复  |  直到 9 年前
        1
  •  9
  •   Andrew Marshall    5 年前

    从…起 man git-describe :

    “g”前缀代表 “git”,用于描述软件的版本 人们可能使用不同SCM的环境。

        2
  •  3
  •   larsks    9 年前

    --long 根据 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....).
    

    随后在同一文档中解释了为什么它添加了 g 哈希的前缀:

    “g”前缀代表“git”,用于描述 软件版本取决于软件管理的SCM 具有这在人们可能使用不同 SCMs。