Ada*_*ruk 1603
这适用于两者git log和gitk- 两种最常见的查看历史记录的方式.您不需要使用整个名称.
git log --author="Jon"
Run Code Online (Sandbox Code Playgroud)
将匹配"乔纳森史密斯"的提交
git log --author=Jon
Run Code Online (Sandbox Code Playgroud)
和
git log --author=Smith
Run Code Online (Sandbox Code Playgroud)
也会有用.如果您不需要任何空格,则引号是可选的.
添加--all如果你打算搜索所有分支,而不是只是在你的回购最近提交的祖先.
您还可以轻松匹配多个作者,因为正则表达式是此过滤器的基础机制.因此,要列出Jonathan或Adam的提交,您可以这样做:
git log --author="\(Adam\)\|\(Jon\)"
Run Code Online (Sandbox Code Playgroud)
为了使用正则表达式排除特定作者或作者集的提交,如本问题所述,您可以将负前瞻与--perl-regexp开关结合使用:
git log --author='^(?!Adam|Jon).*$' --perl-regexp
Run Code Online (Sandbox Code Playgroud)
或者,您可以通过使用bash和管道来排除Adam创作的提交:
git log --format='%H %an' |
grep -v Adam |
cut -d ' ' -f1 |
xargs -n1 git log -1
Run Code Online (Sandbox Code Playgroud)
如果要排除Adam提交(但不一定是创作)的提交,请替换%an为%cn.有关这方面的更多详细信息,请参阅我的博客文章:http://dymitruk.com/blog/2012/07/18/filtering-by-author-name/
slo*_*ott 42
在github上还有一个秘密的方式......
您可以通过附加param在提交视图中按作者过滤提交?author=github_handle.例如,链接https://github.com/dynjs/dynjs/commits/master?author=jingweno显示了Dynjs项目的提交列表
ust*_*tun 31
git help log
Run Code Online (Sandbox Code Playgroud)
为您提供git log的联机帮助页.按/然后键入"author",然后按Enter键搜索"author".输入"n"几次以进入相关部分,其中显示:
git log --author="username"
Run Code Online (Sandbox Code Playgroud)
如已经建议的那样
请注意,这将为您提供提交的作者,但在Git中,作者可以是与提交者不同的人(例如,在Linux内核中,如果您以普通用户身份提交补丁,则可能由另一个管理用户提交) .)请参阅Git中作者和提交者之间的区别?更多细节)
大多数时候,人们指的是用户既是提交者又是作者.
Sir*_*dda 21
提取更多细节 - (这里%an指作者)
用这个 :-
git log --author="username" --pretty=format:"%h - %an, %ar : %s"
Run Code Online (Sandbox Code Playgroud)
Joh*_*lip 17
cat | git log --author="authorName" > author_commits_details.txt
Run Code Online (Sandbox Code Playgroud)
这将以文本格式提交您的提交.
Luc*_*lli 13
如果您想过滤自己的提交:
git log --author="<$(git config user.email)>"
Run Code Online (Sandbox Code Playgroud)
thr*_*ree 12
您甚至可以通过简单地使用部分用户名来缩写它:
git log --author=mr #if you're looking for mrfoobar's commits
Run Code Online (Sandbox Code Playgroud)
试试这个工具 https://github.com/kamranahmedse/git-standup
```bash
$ git standup [-a <author name>]
[-w <weekstart-weekend>]
[-m <max-dir-depth>]
[-f]
[-L]
[-d <days-ago>]
[-D <date-format>]
[-g]
[-h]
```
Run Code Online (Sandbox Code Playgroud)
以下是每个标志的描述
- `-a` - Specify author to restrict search to (name or email)
- `-w` - Specify weekday range to limit search to (e.g. `git standup -w SUN-THU`)
- `-m` - Specify the depth of recursive directory search
- `-L` - Toggle inclusion of symbolic links in recursive directory search
- `-d` - Specify the number of days back to include
- `-D` - Specify the date format for "git log" (default: relative)
- `-h` - Display the help screen
- `-g` - Show if commit is GPG signed or not
- `-f` - Fetch the latest commits beforehand
Run Code Online (Sandbox Code Playgroud)
由于另一个问题(可能是错误地错了?)被锁定,因此我将其放在这里:
向作者显示提交计数:
git shortlog -nse
Run Code Online (Sandbox Code Playgroud)
查找特定USERNAME的所有提交:
git log --author=USERNAME --oneline | awk '{print $1}' | xargs git show
Run Code Online (Sandbox Code Playgroud)
通过在.bashrc文件中添加此小片段,以彩色显示x用户的n个日志。
gitlog() {
if [ "$1" ] && [ "$2" ]; then
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order -n "$1" --author="$2"
elif [ "$1" ]; then
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order -n "$1"
else
git log --pretty=format:"%h%x09 %C(cyan)%an%x09 %Creset%ad%x09 %Cgreen%s" --date-order
fi
}
alias l=gitlog
Run Code Online (Sandbox Code Playgroud)
要显示Frank的最后10次提交:
l 10 frank
要显示任何人的最后20次提交:
l 20