如何找到与给定的git commit相关的标签? [英] How to find the tag associated with a given git commit?
问题描述
对于发行版,我通常使用v1.1.0之类的标签.在构建脚本期间,我正在创建一个包含当前git信息的fwVersion.c文件.目前,我已经提交了文件,并在文件中包含了分支信息,但是我想添加标签.
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, and branch info in the file, but I would like to add the tag.
这可能吗?
推荐答案
检查文档中的git describe
.它找到与给定提交最接近的标签(该标签指向该提交的祖先),并根据该标签描述该提交.
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 <commit-id>
这篇关于如何找到与给定的git commit相关的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!