I moved a file using git mv
. Now I would like to do a diff on the new file to compare it with the old file (with the old, now non-existent name).
How do I do this?
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.