Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you search for multiple words in commit messages?

Tags:

git

grep

I tried to use

git log --grep -e "foo|bar"

but I just got a fatal error.

like image 391
Rohan Wadhwa Avatar asked Aug 28 '18 20:08

Rohan Wadhwa


1 Answers

As mentioned in the docs, it's possible to use several --grep=[pattern] options to extend search for multiple words/patterns. For example, this line:

git log --grep="foo" --grep="bar"

... finds the commits with messages including either foo or bar.

If you need to match only those containing both foo and bar instead, use --all-match option as well:

git log --grep="foo" --grep="bar" --all-match
like image 150
raina77ow Avatar answered Oct 02 '22 07:10

raina77ow