最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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
发布评论

评论列表(0)

  1. 暂无评论