git log 3.5.0
将给出该标签之前的所有提交。git log 3.4.0..3.5.0
将输出这些标签之间的所有提交。如果只想查看标签的提交,请使用git show 3.5.0
。如果您必须查看所有标签及其相应的提交,则可以考虑使用类似于git tag -l | xargs git show
的命令。git log
中添加--decorate
以实际查看与提交关联的标签。git log <commitId>..HEAD tags="project-name"
。从文档中了解到,“如果给出<pattern>,则将标签限制为与给定shell glob匹配的标签”,它应该只匹配模式匹配的标签,但它返回了所有内容。 - rj93--tags
对我也不起作用(或许有人可以给我们解释一下)。根据你的 shell,你可以直接搜索标签列表 git tag -l
,例如 git tag -l | grep 'project'
或者 git tag -l | grep 'project' | xargs git show
。 - SVSchmidttagRegex='foo'; # fill in your tag pattern here
git log --format='%h %D' | sed -n "/ tag: .*$tagRegex/ {s/ .*//; p;q;}";
My tags are of the form
category-v1.2.3
, and I'm interested in the semantic version attached to the tag rather than the commit ID, so I use this:
git log --format='%D' | sed -n "/^tag: .*$tagRegex/ {s/.*-v//; p;q;}";
我曾经遇到过类似的问题,最终来到了这里。我的解决方案是扩展其他答案,得到:
git log <commitId>..HEAD --format='%h %D' | grep '<projectRegex>' | awk '{print $1}' | xargs git show --no-patch
这将为您显示一个git日志样式的历史记录,其中包含在您的commitId和HEAD之间的所有提交的标签(或提交哈希,如果您不幸的话--您可以使用前缀为空格的正则表达式来解决此问题,因为标签不能包含空格--例如\sprojectRegex.*$
)匹配。
逐个解释每个管道符