Recently I wanted to compare some changes I applied in Java projects to the old state before committing my changes to the repository.

eGit staged files for commit, which I did not even touch during development.

Looking at the files using the Compare / Patch view in Eclipse, I saw that eGit was showing all whitespaces in the impacted files as changes.

But nothing had changed, so I would have to clean up before commit or commit unchanged files thereby messing up the repository. In addition the whole file would be stored as changed, not just the actually updated lines.

Searching the internet for a solution I came across a forum on, which provided a root cause analysis and a solution for this bug.

Bug Root Cause and Solution

I will just quote what I found in the forum as it explains what is happening very well.

"The problem for me was due to being on Windows and EGit not respecting the "core.autocrlf" configuration setting. When I run "git config --list" from the command line I can see that "core.autocrlf" is set to "true". But when I open Eclipse Preferences / Team / Git / Configuration, that setting is not listed in any of the tabs."

"There are 2 ways to solve this. The first way is to manually add the "core.autocrlf" setting to "true" in the Eclipse preferences which will solve the problem for Eclipse. However, I think the better solution is to run "git config --global core.autocrlf true" to explicitly set it to true in the global configuration file which Eclipse will then read. Somehow this setting was set for Git command line but was not stored in any of the 3 config files that Eclipse would read."

So, the whole thing happens because the workspace version on Windows machines uses crlf while the index version is changed to unix lf line endings.

There is a configuration setting to respect crlf line endings but Eclipse eGit ignores this configuration.