英文:
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 <the correct options> --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 'release'
1686825873 48c81eb8da3f97703d86241303faec1aa04c1b14 Merge branch 'release'
1686825932 a1b25897c07edce5f872149857d81c9b638892cc merge from dev into dev2
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论