1

I'm trying to find commits whose commit message includes both key words "x" and "y". I've tried using git log --grep="x" --grep="y", and while this does include all commits with X and Y, it also includes those with just X or just Y.

Is there a way to grep by two expressions and inlcude only those which match both?

1
  • 2
    Have a look at git log --help. What you want seems to be the option listed right below --grep, which is --all-match. Alternatively you can use regex in the pattern. E.g.: Looking for commits with "analysis notebook" in them I can use "analysis * notebook" and get what I want, or the two words as separate grep patterns, joined with --all-match Commented Nov 20, 2024 at 9:45

1 Answer 1

2

You need the --all-match flag:

git log --grep="x" --grep="y" --all-match
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.