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

后端 未结 6 671
感情败类
感情败类 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:15

    I found the combo of both top answers to give me what i wanted like so:

    git describe --tags --exact-match 
    

    This gives you the tag that is ONLY for that commit and for ones without annotation. Useful when you want to find tags and not worry about stripping the formatting off then (for Jenkins for example).

    eg. $ git describe --tags --exact-match head~2

    Gives you:

    $ ReleaseBeta
    

提交回复
热议问题