How can I view a git log of just one user's co

2019-01-02 16:40发布

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

13条回答
美炸的是我
2楼-- · 2019-01-02 17:01

You can use either = or "space". For instance following two commands return the same

git log --author="Developer1"

git log --author "Developer1"
查看更多
路过你的时光
3楼-- · 2019-01-02 17:03

On github there is also a secret way...

You can filter commits by author in the commit view by appending param ?author=github_handle. For example, the link https://github.com/dynjs/dynjs/commits/master?author=jingweno shows a list of commits to the Dynjs project

查看更多
余生请多指教
4楼-- · 2019-01-02 17:05

If you want to filter your own commits:

git log --author="<$(git config user.email)>"
查看更多
心情的温度
5楼-- · 2019-01-02 17:06

If using GitHub:

  • go to branch
  • click on commits

it will show list in below format

branch_x: < comment> 
author_name committed 2 days ago
  • to see individual author's commit ; click on author_name and there you can see all the commit's of that author on that branch
查看更多
牵手、夕阳
6楼-- · 2019-01-02 17:07

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/

查看更多
梦该遗忘
7楼-- · 2019-01-02 17:07
git help log

gives you the manpage of git log. Search for "author" there by pressing / and then typing "author", followed by Enter. Type "n" a few times to get to the relevant section, which reveals:

git log --author="username"

as already suggested.

Note that this will give you the author of the commits, but in Git, the author can be someone different from the committer (for example in Linux kernel, if you submit a patch as an ordinary user, it might be committed by another administrative user.) See Difference between author and committer in Git? for more details)

Most of the time, what one refers to as the user is both the committer and the author though.

查看更多
登录 后发表回答