如何在一个git存储库中查找最新提交?
我有一个git存储库,有许多分支和许多提交,我想找到最新的10个提交,如何做到这一点,谢谢 试试这个如何在一个git存储库中查找最新提交?,git,github,Git,Github,我有一个git存储库,有许多分支和许多提交,我想找到最新的10个提交,如何做到这一点,谢谢 试试这个git日志--graph&您将按照从最新到旧的顺序获得提交 •the checksum of the commit •the author name and email •the date the author committed it •the full commit message 编辑: 或者您可以使用: git log--pretty=oneline--graph 它提供了所有提交
git日志--graph
&您将按照从最新到旧的顺序获得提交
•the checksum of the commit
•the author name and email
•the date the author committed it
•the full commit message
编辑:
或者您可以使用:
git log--pretty=oneline--graph
它提供了所有提交和分支拓扑要查找特定数量的提交,您可以使用
-n
选项:
git log -5 # or git log -n 5 # fetches the last 5 commits
正如@honk指出的,-n5
和-5
是等价的
要查找其他分支上的提交,而不签出其他分支,请执行以下操作:
git log branch_name
因此,如果您在develop branch并希望获得master的最后10次提交(oneline),您可以执行以下操作:
git log --oneline master -10
要查看所有分支的提交,有一个--all
参数
git log --all
对于所有分支中的最后10次提交,您可以执行以下操作:
git log --graph --all --format=format:'%h - (%ai) %s — %cn %d' --abbrev-commit --date=relative -10
- %h是提交散列
- %ai是作者日期(使用%ci作为提交人日期)
- %s是提交主题
- %cn是提交者的名称
- -10表示最后10次提交
如果希望提交所有分支,则需要--all参数,使用-10将git log限制为10,并使用--date顺序告诉git log根据日期对提交进行排序
git log -10 --all --date-order
我想获得所有分支中的最新提交,您可以编写
-n5
和-5
是等效的。当然,要查看所有分支,请使用-all
(谈论git CLI有多难)。@honk-yea。我想你指的是——所有的。我会更新答案。谢谢