How to find the latest commits in one git reposito

2020-05-25 02:51发布

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 github
4条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-05-25 03:13

For last 10 commits in all branches, you can do:

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

See here for more info if you need to customize further: http://linux.die.net/man/1/git-log

查看更多
太酷不给撩
3楼-- · 2020-05-25 03:21

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.

git log -10 --all --date-order
查看更多
家丑人穷心不美
4楼-- · 2020-05-25 03:24

To find specific number of commits you can use the -n option :

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

As, @honk pointed out, -n 5 and -5 are equivalent.

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:

git log --oneline master  -10

To view commits of all branches there's a --all argument.

git log --all
查看更多
乱世女痞
5楼-- · 2020-05-25 03:36

Try this git log --graph & you will get the commits in the order latest to old along with

•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

which gives all the commits & branch topology

查看更多
登录 后发表回答