如何在一个 git 存储库中找到最新的提交?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9678890/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to find the latest commits in one git repository?
提问by why
I have one git repository, there are many branches many commits, I want to find the latest 10 commits, how to do this , thanks!
我有一个 git 存储库,有很多分支很多提交,我想找到最新的 10 个提交,如何做到这一点,谢谢!
回答by ralphtheninja
If you want commits for all branches you need the --all argument, limit git log to ten with -10 and use --date-order to tell git log to sort the commits with respect to date.
如果您希望提交所有分支,您需要 --all 参数,使用 -10 将 git log 限制为 10,并使用 --date-order 告诉 git log 根据日期对提交进行排序。
git log -10 --all --date-order
回答by triad
For last 10 commits in all branches, you can do:
对于所有分支中的最后 10 次提交,您可以执行以下操作:
git log --graph --all --format=format:'%h - (%ai) %s — %cn %d' --abbrev-commit --date=relative -10
- %h is the commit hash
- %ai is author date (use %ci for committer date)
- %s is the commit subject
- %cn is the committer name
- -10 means last 10 commits
- %h 是提交哈希
- %ai 是作者日期(使用 %ci 作为提交者日期)
- %s 是提交主题
- %cn 是提交者名称
- -10 表示最近 10 次提交
See here for more info if you need to customize further: http://linux.die.net/man/1/git-log
如果您需要进一步自定义,请在此处查看更多信息:http: //linux.die.net/man/1/git-log
回答by prasvin
To find specific number of commits you can use the -n
option :
要查找特定数量的提交,您可以使用以下-n
选项:
git log -5 # or git log -n 5 # fetches the last 5 commits
As, @honk pointed out, -n 5
and -5
are equivalent.
正如@honk 指出的那样, -n 5
并且-5
是等价的。
To find commits on other branch, without checking out the other branch :
要在其他分支上查找提交,而不检查其他分支:
git log branch_name
So, if you are at develop branch and wish to get last 10 commits of master(oneline), you could do:
因此,如果您在开发分支并希望获得 master(oneline) 的最后 10 次提交,您可以执行以下操作:
git log --oneline master -10
To view commits of all branches there's a --all
argument.
要查看所有分支的提交,有一个--all
论点。
git log --all
回答by uday
Try this git log --graph
& you will get the commits in the order latest to old along with
试试这个git log --graph
,你将按照最新到旧的顺序获得提交
?the checksum of the commit
?the author name and email
?the date the author committed it
?the full commit message
EDIT:
编辑:
or you can use:
或者你可以使用:
git log --pretty=oneline --graph
git log --pretty=oneline --graph
which gives all the commits & branch topology
它提供了所有提交和分支拓扑