How to do a git diff on moved/renamed file?
In addition to what knittl wrote, you can always use:
git diff HEAD:./oldfilename newfilename
where HEAD:./oldfilename
means oldfilename in the last commit (in HEAD), relative to current directory.
If you don't have new enough git, you would have to use instead:
git diff HEAD:path/to/oldfilename newfilename
You need to use -M to let git autodetect the moved file when diffing. Using just git diff
as knittl mentioned does not work for me.
So simply: git diff -M
should do it.
The documentation for this switch is:
-M[<n>], --find-renames[=<n>]
Detect renames. If n is specified, it is a threshold on the similarity index
(i.e. amount of addition/deletions compared to the file’s size). For example,
-M90% means git should consider a delete/add pair to be a rename if more than
90% of the file hasn’t changed.