Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git log to show commits either by author OR commit message

Tags:

git

git-log

I would like to use git log (open to other suggestions) to list all commits that either

  • Were done by a specific author

or

  • Which have a specific word in their commit message

I know how to search for each separately, but I would like a single list containing all matching commits. What is the easiest way to achieve this?

like image 347
franmon Avatar asked Jul 10 '26 02:07

franmon


1 Answers

You can use git rev-list to generate the hash IDs that git log should show, and then use git log --no-walk --stdin to read those IDs, sort them according to the usual git log sorting criteria, and show them. (Note: This will occasionally change the output order from what you would see with git log without --no-walk.)

For instance:

(git rev-list --author 'A. U. Thor' HEAD;
 git rev-list --grep 'pattern' HEAD) |
git log --no-walk --stdin

(split into three lines for posting purposes; some command line interpreters will require that the command be a single line when actually used).

like image 150
torek Avatar answered Jul 11 '26 20:07

torek