Git - Dealing with different line endings on Windows and Linux

Recently I came across a situation where issuing the git status command showed different results on Windows and Linux for the same git repository. On Windows, running the command showed that there were no files to commit and that there were no untracked files. However, when issuing the command on a clone of the same repo on Linux, every file in the repository appeared to have uncommitted changes. git diff revealed that the reason for this was line endings. Windows and Unix-based systems deal with line endings (new line character) differently.

To fix the problem I had to run the following command on Linux:

git config core.autocrlf true

And all my problems were solved.

To read more about dealing with line endings in git repositories see the GitHub Documentation.