Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在一个git存储库中查找最新提交?_Git_Github - Fatal编程技术网

如何在一个git存储库中查找最新提交?

如何在一个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存储库,有许多分支和许多提交,我想找到最新的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


它提供了所有提交和分支拓扑

要查找特定数量的提交,您可以使用
-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。我想你指的是
——所有的
。我会更新答案。谢谢