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

时间:2012-03-13 05:37:22

标签: git github

我有一个git存储库,有许多分支很多提交,我想找到最新的10个提交,如何做到这一点,谢谢!

4 个答案:

答案 0 :(得分:30)

如果你想要所有分支的提交,你需要--all参数,使用-10将git log限制为10并使用--date-order告诉git log对日期的提交进行排序。

git log -10 --all --date-order

答案 1 :(得分:6)

对于所有分支机构的最后10次提交,您可以这样做:

git log --graph --all --format=format:'%h - (%ai) %s — %cn %d' --abbrev-commit --date=relative -10
  • %h是提交哈希
  • %ai是作者日期(使用%ci作为提交者日期)
  • %s是提交主题
  • %cn是提交者名称
  • -10表示最后10次提交

如果您需要进一步定制,请参阅此处了解更多信息: http://linux.die.net/man/1/git-log

答案 2 :(得分:4)

要查找特定数量的提交,您可以使用-n选项:

git log -5  # or git log -n 5 # fetches the last 5 commits

正如@honk指出的那样,-n 5-5是等价的。

要查找其他分支上的提交,而不检查其他分支:

git log branch_name

所以,如果你在开发分支并希望得到最后10个master(oneline)的提交,你可以这样做:

git log --oneline master  -10

要查看所有分支的提交,有一个--all参数。

git log --all

答案 3 :(得分:1)

试试这个git log --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

给出所有提交和&分支拓扑