有没有办法告诉git diff
假定以某种模式开头的行未更改?
例如,考虑以下内容:
$ git diff -U0
diff --git a/file_a.txt b/file_a.txt
index 26ed843..4071ff8 100644
--- a/file_a.txt
+++ b/file_a.txt
@@ -24 +24 @@
- * unimportant foo
+ * unimportant bar
diff --git a/file_b.txt b/file_b.txt
index c6d051e..4b3cf22 100644
--- a/file_b.txt
+++ b/file_b.txt
@@ -24 +24 @@
- * unimportant foo
+ * unimportant bar
@@ -48,0 +49 @@
+ this is important
@@ -56,0 +58 @@
+ this is also important
以星号开头的行(正则表达式模式为"^[[:space:]]*\*.*"
)不重要,我希望从git diff
的输出中仅筛选包含此类行更改的文件。在上面的示例中,输出应仅报告对file_b.txt
的更改。是否可能?