Got some changes I've pulled from another source as a tarball and I'd like to know which files have not changed. The destination is a Git clone, so it's easy to see what's new and what has changed. Anyone know a way to get a list of what has not changed (excluding untracked)?
EDIT: Said another way, I'm hoping to leverage Git to find what preexisting files (in Git) may be absent from the new copy (the tarball).
I haven't been able to find pure git solution, but this is what worked for me:
diff <(git diff --name-only) <(git ls-files -- sub/dir) | grep "^>" | cut -b3-
Explanation of commands used:
git diff --name-only # list modified files
git ls-files -- sub/dir # list all git--tracked files in sub/dir
grep "^>" # match lines starting with '>', i.e. diff's marker for lines present in the second set but not in the first one (i.e. unmodified files)
cut -c3- # remove diff's marker (i.e. remove first two characters)
# <( command ) gives output of the command as a file (diff command needs two files to compare them)
Maybe:
$ git diff --name-only > tmpfile
$ git ls-files -X tmpfile
$ rm tmpfile
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With