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?
No, commit objects in git don't contain diffs - instead, each commit object contains a hash of the tree, which recursively and completely defines the content of the source tree at that commit.
Comparing changes with git diff Diffing is a function that takes two input data sets and outputs the changes between them. git diff is a multi-use Git command that when executed runs a diff function on Git data sources. These data sources can be commits, branches, files and more.
Any binary format can be diffed with git, as long as there's a tool which converts the binary format to plain text. One just needs to add the conversion handlers and attributes in the same way.
You can use git diff --name-status, that will show you files that where added, modified and deleted.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With