Cross platform development using Git (EOL issue)

五迷三道 提交于 2019-12-21 18:12:03

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!