最佳答案
是否有方法显示由给定模式过滤的 git-diff。
差不多
git grepdiff pattern
changed file
+++ some sentence with pattern
changed file 2
--- some other pattern
不幸的是,最简单的解决方案还不够好
git diff | grep pattern
+++ some sentence with pattern
--- some other pattern
# not an option as doesn't put the filename close to the match
我用 awk 解决了这个问题
git diff | awk "/\+\+\+/{f = \$2}; /PATTERN/ {print f \$0} "
但我很想知道有没有这样的命令。