I'm reviewing a big refactor which moved plenty of files around and changing some of the moved files.
When I use
git diff --summary -M master feature/x
I can see many files that have 'similarity percentage' above 95% and when I use git difftool it shows that many of files don't actually have any changes.
When I use
git diff --unified -M master feature/x
it displays the whole contents of renamed files, as removed and then added.
How can I make git diff show me only changed lines in files that it detected as renames?
BTW. What exactly it the percentage number that git displays with --summary?
Why is it 97% when the files look the same?
Try this out:
git diff --unified -M master feature/x --color-words
It should highlight the words that were changed and not the whole file

You are using the -M which is used to display renamed files in the diff.
-M[<n>] --find-renames[=<n>]
Detect renames. If
nis 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. Without a%sign, the number is to be read as a fraction, with a decimal point before it. I.e.,-M5becomes 0.5, and is thus the same as-M50%. Similarly,-M05is the same as-M5%. To limit detection to exact renames, use-M100%. The default similarity index is 50%.Why is it 97% when the files look the same? Have you checked that your white space configuration ignore white space diffs?
Sounds like there is a difference in that (white spaces)
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