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

徘徊边缘 提交于 2019-12-10 17:14:40

问题


like the inverse of git diff --name-only


回答1:


You can do this by looking at unique values from ls-tree and diff with the --name-only options (done in one line so it's 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 the example, the 2 revisions are HEAD and HEAD^. This produces no side effect output files.




回答2:


You could do this using 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


来源:https://stackoverflow.com/questions/11496041/git-get-a-list-of-files-that-are-identical-between-two-revisions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!