“git describe” ignores a tag

后端 未结 4 649
夕颜
夕颜 2020-12-23 19:11

In the following lines:

$ git tag -n1
v1.8        Tagged the day before yesterday
v1.9        Tagged yesterday
v2.0        Tagged today
$ git describe
v1.9-5         


        
4条回答
  •  时光取名叫无心
    2020-12-23 19:30

    Most likely from your example, v1.9 is a tag from merge commit.

    It is expected git behavior by default and you can read more about it here: https://git.kernel.org/pub/scm/git/git.git/commit/?id=80dbae03

    To ignore merge tags when looking for most recent on the current branch you can use --first-parent option.

    git describe --tags --first-parent --abbrev=0
    

    --first-parent

    Follow only the first parent commit upon seeing a merge commit. This is useful when you wish to not match tags on branches merged in the history of the target commit.

    Ref: https://git-scm.com/docs/git-describe

提交回复
热议问题