Reputation: 65034
In a single commit, I moved a function to a new file, and also made some changes to it.
Github's diff viewer just shows ~30 lines deleted from the old file, and 30 lines added to the new file - it's hard to see what differences existed in the implementation of the old file and the new one.
Are there any tools that can help break down this diff? I can copy the relevant sections of each to a new file, and run diff
on these, and generate a patch file I suppose...
Upvotes: 3
Views: 283
Reputation: 5684
The command line git diff
program has a heuristic for detecting renames but it is not turned on by default. Enable it via the -M[<n>]
or --find-renames[=<n>]
option. For example:
git show --find-renames <commit-sha>
As you have experienced, Git does not track renames. The heuristic it employs is to compare files that were deleted and added for similarity. The default similarity index is 50%, but this can be controlled with the =<n>
argument. To increase the threshold to 90% (the files must be 90% the same to be considered a rename):
git show --find-renames=90% <commit-sha>
If you want git to always detect renames, there's a config knob for that:
git config --global diff.renames=true
For more information see the git-diff
documentation.
Upvotes: 2