This works for both git log
and gitk
- the 2 most common ways of viewing history.
(这适用于git log
和gitk
查看历史记录的两种最常见方式。)
You don't need to use the whole name. (您不需要使用全名。)
git log --author="Jon"
will match a commit made by "Jonathan Smith"
(将匹配“乔纳森·史密斯”的承诺)
git log --author=Jon
and
(和)
git log --author=Smith
would also work.
(也可以。)
The quotes are optional if you don't need any spaces. (如果不需要空格,则引号是可选的。)
Add --all
if you intend to search all branches and not just the current commit's ancestors in your repo.
(如果要搜索所有分支,而不是仅搜索--all
当前提交的祖先,请添加--all
。)
You can also easily match on multiple authors as regex is the underlying mechanism for this filter.
(您也可以轻松匹配多个作者,因为正则表达式是此过滤器的基础机制。)
So to list commits by Jonathan or Adam, you can do this: (因此,要列出Jonathan或Adam的提交,可以执行以下操作:)
git log --author="(Adam)|(Jon)"
In order to exclude commits by a particular author or set of authors using regular expressions as noted in this question , you can use a negative lookahead in combination with the --perl-regexp
switch:
(为了排除特定作者或一组作者使用正则表达式的提交(如本问题所述) ,可以结合使用否定超前查询和--perl-regexp
开关:)
git log --author='^(?!Adam|Jon).*$' --perl-regexp
Alternatively, you can exclude commits authored by Adam by using bash
and piping:
(另外,您可以使用bash
和管道排除由Adam创作的提交:)
git log --format='%H %an' |
grep -v Adam |
cut -d ' ' -f1 |
xargs -n1 git log -1
If you want to exclude commits commited (but not necessarily authored) by Adam, replace %an
with %cn
.
(如果要排除Adam提交(但不一定是作者)的提交,请将%an
替换%an
%cn
。)
More details about this are in my blog post here: http://dymitruk.com/blog/2012/07/18/filtering-by-author-name/ (有关此操作的更多详细信息,请参见我的博客文章: http : //dymitruk.com/blog/2012/07/18/filtering-by-author-name/)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…