Git:如何在不同的提交中区分两个不同的文件?

问题描述:

我有一个存储库,自上次提取以来,许多文件已从.html重命名为.php,并在许多提交中进行了进一步编辑。使用 git diff 显示已删除的所有 html 内容和所有 php 内容已添加。是否有一种巧妙的方法让 git diff 检测到重命名(类似于 git log --follow 那样),或者直接比较不同提交之间的不同文件名(类似于 Git:如何在不同的分支中区分两个不同的文件?,但要提交)?

I have a repository where a number of files have been renamed from .html to .php and further edited in a number of commits since my last pull. Using git diff to shows all the html contents removed and all the php content added. Is there a neat way to have git diff detect the renames (something like git log --follow does), or directly compare different filenames across different commits (something like the solution in Git: How to diff two different files in different branches? , but for commits)?

总是比较2个不同提交中的2个文件:

You can always compare 2 files in 2 different commits:

git diff commit1:file1_path commit2:file2_path