diff returning entire file for identical files
Most likely it's line termination. Try git diff --ignore-space-at-eol
. And for plain (not git
) diff it's diff -b
.
I was just having this issue in a JetBrains IDE and it was because when I saved the file, the IDE was changing the line endings. I just needed to go to the bottom-right corner and switch the line endings back to their original setting to make the diff look right.
This seems like a whitespace issue, in order to avoid them in the future, you can setup Git to normalize them.
Windows and UNIX system don't use same line-ending, to prevent conflict from happening based on these, you should setup you git config this way:
- Windows :
git config --global core.autocrlf true
- Unix :
git config --global core.autocrlf input
Next, to make sure we only commit with ideal whitespace rules, you can set this config option:
git config --global core.whitespace trailing-space,space-before-tab,indent-with-non-tab
That usually means the line endings are different. Most diffin programs allow you to ignore differences in line endings. Does yours allow you to do so?