I really like git diff's output format, and I use it a lot as git diff --no-index
to compare arbitrary non-git-related files. But as far as I can tell when using –no-index you can provide only a single pair of files. I'd really like to be able to pass it multiple pairs, like:
git diff --no-index a.new a.old b.new b.old
And get the kind of output you'd get by running git diff
in a repo:
diff --git a/a b/a
index e965047..ce01362 100644
--- a/a
+++ b/a
@@ -1 +1 @@
-Hello
+hello
diff --git a/b b/b
index 2b60207..dd7e1c6 100644
--- a/b
+++ b/b
@@ -1 +1 @@
-Goodbye
+goodbye
Is there any way to do this with git diff, or a similar tool?
Best Answer
Since
git diff --no-index
accepts also two directories and compare these, you could always write a wrapper script around that, copying your files into two temporary directories.Other than that, I don't know of a diff tool that accepts multiple pairs of files to compare. Even
diff
only accepts a single pair of files, or a directory and a list of files.