我有一个 Git 仓库,其中有许多分支和提交记录。我想找到最近的10个提交记录,应该如何操作?谢谢!
如果你想要所有分支的提交记录,需要使用 --all 参数,使用 -10 限制 git log 只显示最近的十条记录,并且使用 --date-order 告诉 git log 按照日期顺序排序提交记录。
git log -10 --all --date-order
获取所有分支的最近10个提交记录,可以执行以下操作:
git log --graph --all --format=format:'%h - (%ai) %s — %cn %d' \
--abbrev-commit --date=relative -10
如果您需要进一步自定义,请参阅此处获取更多信息: http://linux.die.net/man/1/git-log
-n
选项:git log -5 # or git log -n 5 # fetches the last 5 commits
正如@honk指出的,-n 5
和-5
是等价的。
查找其他分支上的提交,而不必检出其他分支:
git log branch_name
如果你在develop分支上,并希望获取master分支最后的10个提交记录(单行显示),你可以执行以下命令:
git log --oneline master -10
--all
参数。git log --all
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
这会显示所有的提交和分支拓扑结构
-n 5
和-5
是等价的。而要查看所有分支,当然要使用-all
(谈论 git CLI 的难度)。 - Benjamin Bannier--all
。我会更新答案。谢谢。 - prasvin