10

有没有办法让 git 列出两次提交之间添加的所有标签?也就是说,只显示出现在 A 点和 B 点之间的标签。

4

3 回答 3

10

您可以将git log命令与以下选项一起使用:

git log tagA...tagB --decorate --simplify-by-decoration

--decorate在提交旁边显示标签名称,并--simplify-by-decoration仅显示已标记的提交。

于 2013-05-09T01:33:48.963 回答
5

如果您commit1想要and之间的标签名称列表(按时间倒序)commit2,您可以git log结合xargsand git tag --points-at

git log commit1..commit2 --simplify-by-decoration --format=format:%h | xargs -L1 git tag --points-at
于 2014-02-17T17:07:47.503 回答
1

commit1该命令有效地列出了提交和commit2(不包括commit1其自身)之间的所有标签。

git log --simplify-by-decoration --pretty=format:%D commit1..commit2 | \
    grep -o 'tag: [^,)]\+' | sed 's/^tag: //'

git log ...命令列出了引用指定范围内每个提交的分支和标签。随后的命令只解析出标签。

于 2020-08-20T22:24:01.223 回答