Git,查看我最近 N 次提交的评论列表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13542213/
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
Git, see a list of comments of my last N commits
提问by Salvador Dali
Is there a way to see a list of comments and time of my last N commits in Git?
有没有办法在 Git 中查看我最近 N 次提交的评论列表和时间?
After looking on SO, the only relevant thing I have found is Git - get all commits and blobs they created, but it shows all commits from all users, and outputs a lot of other information.
在查看 SO 之后,我发现唯一相关的是 Git - 获取他们创建的所有提交和 blob,但它显示了所有用户的所有提交,并输出了许多其他信息。
回答by Abizern
If you want to use the command line you can use the --author=<your name>
如果你想使用命令行,你可以使用 --author=<your name>
For example: to see your last 5 commits
例如:查看您最近的 5 次提交
git log -n 5 --author=Salvador
If you want a simpler one line solution:
如果您想要更简单的单行解决方案:
git log --oneline -n 5 --author=Salvador
Edited to add
编辑添加
If you like the single line version, try creating an alias for git log
like this (this is what I have for zsh)
如果您喜欢单行版本,请尝试为git log
这样创建别名(这就是我为 zsh 所做的)
alias glog="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
Now, I can just use:
现在,我可以使用:
glog -n 5
And I get a nice output such as:
我得到了一个不错的输出,例如:
Which is colourised, shows the name of the author and also shows the graph and you can still pass in other flags (such as --author) which lets you filter it even more.
这是彩色的,显示作者的姓名,还显示图表,您仍然可以传入其他标志(例如--author),让您对其进行更多过滤。
回答by Delan Azabani
Use the --author
and/or --committer
filtering options with git log
, plus the -n
option to limit the number of commits. For example:
使用--author
和/或--committer
过滤选项和git log
,以及-n
限制提交次数的选项。例如:
git log --author='Salvador Dali' -n 10
回答by Firesh
git log --format="%h %B" --oneline -n 1
This will get you latest git log comment block with abbreviated commit id.
这将为您提供带有缩写提交 ID 的最新 git 日志注释块。
git log --format="%h %B" --oneline -n 1
This will get you latest git log comment block with full commit id.
这将为您提供具有完整提交 ID 的最新 git 日志注释块。
You can build your own format from : Git Pretty Format
您可以从以下位置构建自己的格式:Git Pretty Format
回答by chelmertz
git log --author="My name" -n 5
(see man git-log
for all alternatives)
git log --author="My name" -n 5
(查看man git-log
所有替代方案)