多个提交的详细信息

huangapple go评论104阅读模式
英文:

Details of multiple commit at once

问题

我今天有一台能够使用 git rev-list 读取单个提交详细信息的机器,例如:

$ git rev-list --timestamp --max-count=1 {hash}

但是,我可能需要获取更多的提交详情。因此,我想要减少对从另一个运行时调用的 git 命令的调用次数。

我没有找到一种方法可以使用 git rev-list 以便只打印传递的引用,类似于:

$ git rev-list <正确的选项> --timestamp --pretty=oneline {H1} {H2} ... {Hn}
1688476824 f670d3bf2b845b526ec99e4ef4dfbe25532023bd chore: work 1
1688476399 f90b69ef94a69fc905233179ef8cc58aaeed3ebb chore: work 2
...
1688474513 b93876fb4665d9cc343e03f763f5a24dda63e85f chore: work n

不幸的是,我的尝试使 git rev-list 打印了所有以前的提交。

请注意,--max-count 似乎适用于整个输出,就像 head -n 1 一样。

如果使用 git 命令可以实现这个目标,我想知道如何做到。谢谢您提前的帮助。

英文:

I have today a machinery that is able to read single commit details using git rev-list, e.g.

$ git rev-list --timestamp --max-count=1 {hash}

However I may have more than one commit to get details from. And as such I would like to reduce the invocation of the git command, which is called from another runtime.

I didn't found a way to use git rev-list so that only the references are passed are printed.

Something like that

$ git rev-list &lt;the correct options&gt; --timestamp --pretty=oneline {H1} {H2} ... {Hn}
1688476824 f670d3bf2b845b526ec99e4ef4dfbe25532023bd chore: work 1
1688476399 f90b69ef94a69fc905233179ef8cc58aaeed3ebb chore: work 2
...
1688474513 b93876fb4665d9cc343e03f763f5a24dda63e85f chore: work n

Unfortunately my attempts made git rev-list print all previous commits.

Note --max-count applies to the whole output it seems like head -n 1.

If this is possible with git commands, I'd like to know how.
Thank you in advance.

答案1

得分: 3

你需要添加 --no-walk 参数,这样只会打印你的引用的最后提交,不要忘记删除 -n1--max-count=1 选项。

你可以添加 unsorted 值到选项中,这样提交将以与引用相同的顺序列出(对自动化可能有用)。

https://git-scm.com/docs/git-rev-list#Documentation/git-rev-list.txt---no-walksortedunsorted

$ git rev-list --timestamp --pretty=oneline --no-walk=unsorted master dev dev2
1688456154 cbf93280b240df1d5c586729c6c32c96b4f38788 合并分支 'release'
1686825873 48c81eb8da3f97703d86241303faec1aa04c1b14 合并分支 'release'
1686825932 a1b25897c07edce5f872149857d81c9b638892cc 从 dev 合并到 dev2
英文:

You need to add --no-walk so only the last commits of your refs would be printed, don't forget to remove the -n1 or --max-count=1 option.

You can add unsorted value to the option so the commits would be listed the same order as refs (could be useful for automation).

https://git-scm.com/docs/git-rev-list#Documentation/git-rev-list.txt---no-walksortedunsorted

$ git rev-list --timestamp --pretty=oneline --no-walk=unsorted master dev dev2
1688456154 cbf93280b240df1d5c586729c6c32c96b4f38788 Merge branch &#39;release&#39;
1686825873 48c81eb8da3f97703d86241303faec1aa04c1b14 Merge branch &#39;release&#39;
1686825932 a1b25897c07edce5f872149857d81c9b638892cc merge from dev into dev2

huangapple
  • 本文由 发表于 2023年7月5日 00:10:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76614359.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定