Rohan Wadhwa
Rohan Wadhwa

Reputation: 191

How do you search for multiple words in commit messages?

I tried to use

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

but I just got a fatal error.

Upvotes: 19

Views: 4292

Answers (1)

raina77ow
raina77ow

Reputation: 106365

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

Upvotes: 26

Related Questions