如何grep git diff?

因为

有没有办法显示通过给定模式过滤的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} "

但是很乐意找出对此有一个命令。

查尔斯·B

不确定但git diff -G <regex>标记不正确吗?

-G <正则表达式>

Look for differences whose added or removed line matches the given <regex>.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章