admin管理员组

文章数量:1334326

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
  • 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 – Nox Commented Nov 20, 2024 at 9:45
Add a comment  | 

1 Answer 1

Reset to default 2

You need the --all-match flag:

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

本文标签: git logUsing quotx AND yquot instead of quotx OR yquot when using grep twice in gitlogStack Overflow