gitgit-log

Using "x AND y" instead of "x OR y" when using --grep twice in git-log


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?


Solution

  • You need the --all-match flag:

    git log --grep="x" --grep="y" --all-match