When using git log
, how can I filter by user so that I see only commits from that user?
Git – How to view a git log of just one user’s commits
gitgit-logversion control
Related Topic
- Git – How to undo ‘git add’ before commit
- Git – How to undo the most recent local commits in Git
- Git: How to force “git pull” to overwrite local files
- Git – Move the most recent commit(s) to a new branch with Git
- Git – How to check out a remote Git branch
- Git – How to delete a Git branch locally and remotely
- Git – Squash the last X commits together using Git
- Git – How to rename a local Git branch
Best Answer
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:
will match a commit made by "Jonathan Smith"
and
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:
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:Alternatively, you can exclude commits authored by Adam by using
bash
and piping: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/