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?
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?
Share Improve this question edited Nov 20, 2024 at 10:28 phd 95.2k14 gold badges158 silver badges207 bronze badges asked Nov 20, 2024 at 9:39 Josh BruntonJosh Brunton 5461 silver badge20 bronze badges 1 |1 Answer
Reset to default 2You need the --all-match
flag:
git log --grep="x" --grep="y" --all-match
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742368251a4430749.html
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
– Nox Commented Nov 20, 2024 at 9:45