Git - get a list of files that are identical between two versions

like the inverse of git diff --name-only

+4
source share
2 answers

You can do this by looking at the unique values ​​from ls-tree and diff with the --name-only parameters (made in one line, which makes it easier to search and use from history later):

 cat <(git ls-tree --name-only -r HEAD) <(git diff --name-only HEAD^ HEAD) | sort | uniq -u 

In this example, two revisions are HEAD and HEAD ^. This does not produce side effect output files.

+1
source

You can do this with the comm command and some shell commands:

 git ls-files >files.txt git diff --name-only >diff.txt comm -2 -3 files.txt diff.txt 
+2
source

All Articles