有沒有辦法顯示由給定模式過濾的git-diff。如何grep 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} "
但很想發現,有是這個命令。
很顯然github項目名爲git-diff-grep做了一些完全不同的事情。 – Kuba