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

I'm trying to find commits whose commit message includes both key words "x" and "y&

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742368251a4430749.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信