如何grep的GIT差异? [英] How to grep the git diff?
本文介绍了如何grep的GIT差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
类似于
<$>
有没有办法显示按给定模式过滤的git-diff。 p $ p> git grepdiff模式
改变文件
+++一些带模式的句子
改变文件2
---其他模式
不幸的是,最简单的解决方案不够好
git diff | grep模式
+++一些带模式的句子
---一些其他模式
#不是一个选项,因为不会将文件名接近匹配
我使用了awk的解决方法
git diff | awk/ \ + \ + \ + / {f = \ $ 2}; / PATTERN / {print f \ $ 0}
但是很想知道这是一个命令。
解决方案
不确定但不是 git diff -G< regex>
flag ok?
-G <正则表达式>
查找添加或删除的行与给定的< regex>匹配的区别。
Is there a way to show the git-diff filtered by a given pattern.
Something like
git grepdiff pattern
changed file
+++ some sentence with pattern
changed file 2
--- some other pattern
Unfortunately the simplest solution is not good enough
git diff | grep pattern
+++ some sentence with pattern
--- some other pattern
# not an option as doesn't put the filename close to the match
I came with a workaround using awk
git diff | awk "/\+\+\+/{f = \$2}; /PATTERN/ {print f \$0} "
But would love to find out that there is a command for this.
解决方案
Not sure but isn't git diff -G <regex>
flag OK?
-G < regex>
Look for differences whose added or removed line matches the given <regex>.
这篇关于如何grep的GIT差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文