我如何查看一个用户提交的git日志? [英] How can I view a git log of just one user's commits?

查看:1857
本文介绍了我如何查看一个用户提交的git日志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用 git log 时,如何过滤用户,以便仅查看该用户提交的内容?

git log 和 gitk - 都是最有效的常见的观看历史的方式。您不需要使用全名。

  git log --author =Jon

code>

将与Jonathan Smith提交的内容匹配

  git log --author = Jon 

  git log --author = Smith 

也可以工作。如果您不需要任何空格,引号是可选的。

添加 - 全部打算搜索所有分支,而不是搜索当前提交的祖先。



您也可以轻松匹配多个作者,因为正则表达式是这个过滤器。所以要列出乔纳森或亚当的提交,你可以这样做:

  git log --author =\(Adam \\ \\)\ | \(Jon \)

为了排除特定的提交作者或使用正则表达式的作者集在这个问题中,您可以将负向预测 - perl-regexp switch:

  git log --author ='^(?! Adam | Jon)。* $'--perl-regexp 

或者,您可以排除由Adam使用 bash 和管道:

  git log --format = '%H%an'| 
grep -v Adam |
cut -d''-f1 |
xargs -n1 git log -1

如果您想排除提交提交(但不能必须由Adam创作),用%cn 替换%an 。有关这方面的更多详情,请参阅我的博客文章: http:/ /dymitruk.com/blog/2012/07/18/filtering-by-author-name/


When using git log, how can I filter by user so that I see only commits from that user?

解决方案

This works for both git log and gitk - the 2 most common ways of viewing history. 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.

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:

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:

git log --author='^(?!Adam|Jon).*$' --perl-regexp

Alternatively, you can exclude commits authored by Adam by using bash and piping:

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. More details about this are in my blog post here: http://dymitruk.com/blog/2012/07/18/filtering-by-author-name/

这篇关于我如何查看一个用户提交的git日志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆