Reputation: 35982
I have referred to https://help.github.com/articles/dealing-with-line-endings/#platform-linux and set * text=auto
in .gitattributes
.
Here is the issue I have:
The git repository is set on a network drive and I can access it through windows or Linux. If I run git.exe( ver 2.5.3.windows.1), I will see many unstaged files.
git.exe diff HEAD
However, if I run git(ver 2.5.3) under linux, I will see none of the unstaged files.
The reason why the windows Git reports difference is that the unstaged files have linux ending while the commited files are with windows line ending.
Question> Why different version of Gits report different results here?
Thank you
Upvotes: 2
Views: 631
Reputation: 1539
With text=auto
, git will commit with LF endings and checkout with CRLF endings on Windows, but use exclusively LF on Linux. This works fine if some cloners are using Windows and others are using Linux but if different OSes are sharing a network drive, they'll disagree about what the line endings in the working copy should be.
If you add the files, you should get a message for each one:
warning: LF will be replaced by CRLF in my-file.txt.
The file will have its original line endings in your working directory.
Git will automatically handle the line endings when you commit, so you don't really have to do anything. But if you want to keep line ending mismatches from clogging the output of git status
, git diff
, etc., you can change your .gitattributes to use LF for everything (assuming this won't break anything for you on Windows):
* text eol=lf
Upvotes: 3