views:

235

answers:

2

The diff functionality in git has "copy detection"--if it detects that a new file is actually a (possibly modified) copy of an existing file, the diff output shows the differences between the source file and the new file rather than just a bunch of additions from a blank file to the new file.

As far as I can tell, git diff uses some heuristics to detect this situation. Unfortunately it is not detecting a particular new file as a copy of another file because I guess it has changed too much. I'd still like to view the diff as though it were a copy. Is there a way to inform git diff that the new file is a copy of another so that it will do this for me?

+1  A: 

git diff (at least my version 1.5.6 does) comes with the switch --find-copies-harder, which does more cpu-intensive copy detection than the regular -C does.

antifuchs
I tried --find-copies-harder and it still didn't detect my new file as a copy of an existing file.
nohat
A: 

Just want to make sure it was added to the git repo.

Also if you know the original file, why not use diff directly?

sfossen
Using diff directly works great, but I'd like the diff to be included in my `git diff` results.
nohat
has the new file been added to the git repo?
sfossen