How to find the tag associated with a given git commit?

后端 未结 6 664
感情败类
感情败类 2020-12-23 02:41

For releases I usually tag with something like v1.1.0. During my build script I am creating a fwVersion.c file that contains the current git info. Currently, I have commit

6条回答
  •  爱一瞬间的悲伤
    2020-12-23 03:14

    Check the documentation for git describe. It finds the nearest tag to a given commit (that is a tag which points to an ancestor of the commit) and describes that commit in terms of the tag.

    If you only want to know if the commit is pointed to by a tag then you can check the output of:

    git describe --exact-match 
    

提交回复
热议问题