跨平台开发使用Git(EOL问题) [英] Cross platform development using Git (EOL issue)

查看:703
本文介绍了跨平台开发使用Git(EOL问题)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的开发环境中,我们使用Windows,Mac和Linux。当涉及到 commit - >时,我遇到了麻烦。拉 - >推送工作流程。



问题在于行尾字符。如果有人在Mac上进行编辑,而其他人在Windows上进行编辑,则在拉动时会发生冲突。差异显示整个文件不同,因为行结束有变化。



所以我的问题是我如何设置所有环境来提交时所有行结束LF 。

解决方案

您要求的是用于每个人都需要将配置参数 core.autocrlf 设置为 input ,这会导致输入行结束标准化(也就是说,数据进入存储库;提交)而不是输出(数据从存储库中取出;检出,在拉取过程中发生)。

但是,您可能不实际上想要做到这一点。理想的是每个人都可以正确配置他们的编辑器。大多数程序员的编辑对此都非常聪明 - 他们会在回写文件时检测行尾,并使用相同的行结束符。一些编辑可能需要一些帮助。



(请参阅VonC的答案 here 和其他关于autocrlf的SO问题。)


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.

解决方案

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.)

这篇关于跨平台开发使用Git(EOL问题)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆