我有4个这样的目录:
root/
|
|
|---dir1/
| |---file1.js
| |---file2.js
|
|---dir2/
| |---file3.js
|
|---dir3/
| |---dir4/
| |----file23.js
我正在寻找一种类似git diff <pattern>
的模式,以便在一个命令中显示所有这些文件的差异。
我已经尝试了git diff path/to/root/**/*.js
,但它只显示了file1,file2和file3.js。
谢谢!
编辑:
更具体地说,我希望将所有.js文件的差异放在controllers目录中。我已经尝试git diff path/to/root/controllers/**/*.js
root/
|
|---services/
|
|---controllers/
|
|
|---dir1/
| |---controller1.js
| |---controller2.js
|
|---dir2/
|---controller3.js
|
|---dir3/
|---dir4/
|----controller34.js
答案 0 :(得分:2)
git diff 默认显示当前文件状态与 staging area 之间的差异。
[folkol@localhost (master)]$ git diff
diff --git a/dir1/file1.js b/dir1/file1.js
index 3be9c81..c82de6a 100644
--- a/dir1/file1.js
+++ b/dir1/file1.js
@@ -1 +1,2 @@
Line 1
+Line 2
diff --git a/dir1/file2.js b/dir1/file2.js
index 3be9c81..c82de6a 100644
--- a/dir1/file2.js
+++ b/dir1/file2.js
@@ -1 +1,2 @@
Line 1
+Line 2
diff --git a/dir2/file3.js b/dir2/file3.js
index 3be9c81..c82de6a 100644
--- a/dir2/file3.js
+++ b/dir2/file3.js
@@ -1 +1,2 @@
Line 1
+Line 2
diff --git a/dir3/dir4/file23.js b/dir3/dir4/file23.js
index 3be9c81..c82de6a 100644
--- a/dir3/dir4/file23.js
+++ b/dir3/dir4/file23.js
@@ -1 +1,2 @@
Line 1
+Line 2
编辑:如果您只对.js文件感兴趣,可以使用以下模式:
git diff -- '*js'
再次编辑,由于更新的问题:如果你想在控制器下的所有.js文件:
git diff -- controllers/*js