有没有办法显示通过给定模式过滤的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} "
但是很乐意找出对此有一个命令。