问题
In our development environment we use Windows, Mac, and Linux. I am having trouble when it comes to the commit -> pull -> push
work flow.
The problem is end of line characters. If someone makes an edit on Mac and some one else makes an edit on Windows they conflict when pulling. The diff shows the entire file as different because the line endings have changes.
So my question is how can I setup all environments to convert all line endings to just LF when committing. And when pulling, don't change the line ending, leave it as LF.
回答1:
What you're asking for is for everyone to set the config parameter core.autocrlf
to input
, which will cause line ending normalization on input (that is, data going into the repository; committing) but not on output (data coming out of the repository; checking out, which happens during a pull).
However, you may not actually want to do this. The ideal thing is for everyone to simply configure their editors correctly. Most programmers' editors are reasonably intelligent about this - they'll detect line endings and use the same line endings when writing back to the file. Some editors may need a little help.
(See for example VonC's answer here, and other SO questions about autocrlf.)
来源:https://stackoverflow.com/questions/3983159/cross-platform-development-using-git-eol-issue