I have four directories like so:
root/
|
|
|---dir1/
| |---file1.js
| |---file2.js
|
|---dir2/
| |---file3.js
|
|---dir3/
| |---dir4/
| |----file23.js
I'm looking for a pattern to use like git diff <pattern>
to display the diff of all those files in one command.
I've already tried git diff path/to/root/**/*.js
, but it's only displaying file1, file2, and file3.js.
To be more specific, I’d like to have the diff of all my .js files located in the controllers directory. I’ve already tried git diff path/to/root/controllers/**/*.js
.
root/
|
|---services/
|
|---controllers/
|
|
|---dir1/
| |---controller1.js
| |---controller2.js
|
|---dir2/
|---controller3.js
|
|---dir3/
|---dir4/
|----controller34.js
git diff will by default show the difference between the current file state and the staging area, for all files in the repository.
git diff
Output:
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
If you are only interested in the .js-files, you can use this pattern:
git diff -- '*js'
If you want all .js files under controller:
git diff -- controllers/*js