过滤git日志以仅显示我的更改


92

如何过滤git log来仅显示我的更改(不包括其他开发人员提交的更改)?

Answers:


109

例如,您可以按作者过滤日志,因此可以按名称过滤:

git log --author="YourName"

或通过提交者:

 git log --committer="YourName"

2
另外,可以使用任意数量的组合使结果看起来更漂亮git log --author ='Your Name'-oneline --pretty = format:'%h%x09%an%x09%ad%x09%s '--date = short或git log --pretty = format:“%h%x09%an%x09%ad%x09%s”
--author

-i启用了不区分大小写的正则表达式,其值为--author
Trevor Boyd Smith,

30

您应该--authorgit-log命令中使用标志

像这样:

git log --author="You Name"

名称的一部分也起作用:

git log --author=Name

但是,如果您想在本技巧之类的通用脚本中使用,可以这样做:

git log --author="$(git config user.name)"

然后,您可以做一个别名:

git config --global alias.mylog '!git log --author="$(git config user.name)"'

然后,您可以键入:git mylog并且仅查看您的提交。


git log --author =“ $(git config user.name)”在Windows上似乎不起作用。有什么建议?
安德烈亚斯·普雷斯特哈默

@AndreasPresthammer我不确定您是否仍在想这个问题,但是如果您的问题是设置别名,但是如果您是在文本编辑器中而不是通过git bash设置此别名,则可能是未转义的双引号引起的问题(至少,我遇到了这样的问题)。在Windows的.gitconfig中,我设置了这些别名,并且它们对我有用。 my-history = !git log --author=\"$(git config user.name)\"
纳尔逊·O
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.