鱼C论坛

 找回密码
 立即注册
查看: 2155|回复: 0

[技术交流] [git] warning: LF will be replaced by CRLF

[复制链接]
发表于 2016-4-28 09:43:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
在学习小甲鱼的Git实用教程4时,发现一个警告:
[git] warning: LF will be replaced by CRLF


解决方法为:
在git bash  输入下面的命令:
git config --global core.autocrlf  false



原因是:
不同的操作系统,换行的方式不同,不设置改命令的时候, line feed(换行)
会被替换为 carriage return & line feed(回车&换行)

其实回车的意思是,光标回到本行的最前面,而换行的意思是光标下移一行。
在windows中,(回车&换行)用\r\n表示。而在linux中直接是\n表示。



当设置为false后,解释为:
no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok, as long as all your developers are either on Linux or all on Windows. But in my experience I still tend to get text files with mixed line endings that end up causing problems.

当设置为ture,解释为:
If core.autocrlf is set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit. Whenever you git checkout something, all text files automatically will have their LF line endings converted to CRLF endings. This allows development of a project across platforms that use different line-ending styles without commits being very noisy because each editor changes the line ending style as the line ending style is always consistently LF.
  The side-effect of this convenient conversion, and this is what the warning you’re seeing is about, is that if a text file you authored originally had LF endings instead of CRLF, it will be stored with LF as usual, but when checked out later it will have CRLF endings. For normal text files this is usually just fine. The warning is a “for your information” in this case, but in case git incorrectly assesses a binary file to be a text file, it is an important warning because git would then be corrupting your binary file.


你会选择哪个一个呢?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-3-29 16:39

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表