Search code examples
gitdiffcommit

Git: How to diff two different files in different commits?


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)?


Solution

  • You can always compare 2 files in 2 different commits:

    git diff commit1:file1_path commit2:file2_path