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

mu0hgdu0  于 2022-12-17  发布在  Git
关注(0)|答案(4)|浏览(260)

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

w7t8yxp5

w7t8yxp51#

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

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

myzjeezk2#

对于所有分支中的最后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

unhi4e5o

unhi4e5o3#

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

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

正如@honk指出的那样,-n 5-5是等价的。
查找其他分支上的提交,而不 checkout 其他分支:

git log branch_name

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

git log --oneline master  -10

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

git log --all
eivnm1vs

eivnm1vs4#

试试这个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
它给出了所有提交和分支拓扑

相关问题