From man git diff
(on Linux Ubuntu 20.04):
git diff [<options>] --no-index [--] <path> <path>
This form is to compare the given two paths on the
filesystem. You can omit the --no-index option when
running the command in a working tree controlled by Git
and at least one of the paths points outside the
working tree, or when running the command outside a
working tree controlled by Git. This form implies
--exit-code.
So, apparently something like this would work:
git diff --no-index -- /some/path1 /some/path2
Store the output into a file with:
git diff --no-index -- /some/path1 /some/path2 > mydiff.txt
...or with color output via ANSI color codes:
git diff --no-index --color=always -- /some/path1 /some/path2 > mydiff.txt
You could also just manually force both sets of files into a new git repo to see how they differ:
# make a new git repo
mkdir newrepo
cd newrepo
git init
# copy the first set of files into it (manually delete the .git
# folder in this set of files **before copying them**, if it has one,
# as you do NOT want to overwrite the destination .git folder)
cp -r /some/path1 .
# add them to the repo
git add -A
git commit
# manually delete everything in the repo except the .git folder
# copy 2nd set of files into repo (manually delete the .git
# folder in this set of files **before copying them**, if it has one,
# as you do NOT want to overwrite the destination .git folder)
cp -r /some/path2 .
# add them to the repo
git add -A
git commit
# compare the two sets of files by comparing your previous
# commit (with files from "/some/path1") to your current
# commit (with files from "/some/path2").
git diff HEAD~..HEAD
# OR (same thing):
git diff HEAD~
References:
man git diff
- The other answer by @Nick Volynkin: How to diff two local repositories