You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何查找包含特定词汇的Git提交信息?含wordA与wordB多词查询方法

Git Commit History Search: Target Specific Terms & Combined Matches

Hey there! Let’s walk through the exact Git commands you need to tackle both of your commit search scenarios.

1. Find commits containing a specific term in their message

To locate commits where the commit message includes a particular word or phrase, use Git’s --grep flag with git log:

git log --grep="your-target-term"
  • Add -i if you want a case-insensitive search (so "Term" and "term" both count):
    git log --grep="your-target-term" -i
    
  • Use --oneline for condensed, easier-to-scan output (shows only the commit hash and short message):
    git log --grep="your-target-term" --oneline
    

2. Find commits with both wordA AND wordB in their message

By default, multiple --grep flags will match commits that have either term. To enforce an AND condition (both terms must appear in the same commit message), add the --all-match flag:

git log --grep="wordA" --grep="wordB" --all-match

You can combine this with the same convenience flags as before:

git log --grep="wordA" --grep="wordB" --all-match -i --oneline

Bonus: Search code changes (not just commit messages)

If you ever need to find commits where the actual code includes your target terms (not just the commit message), use git log -S:

# Find commits where wordA was added/removed in code
git log -S"wordA"
# Find commits with both wordA AND wordB in code changes
git log -S"wordA" -S"wordB" --all-match

内容的提问来源于stack exchange,提问作者Druudik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 08:10:46