Git中“ LF will be replaced by CRLF in... ”警告解决方法

原因

不同操作系统行尾结束符不一样:

 Uinx/Linux  --- \n(LF);
 windows   --- \r\n(CRLF)

在windows下用git拉取文件,会自动用CRLF替换掉LF; 同样,用git提交文件时,也需要将CRLF替换成LF。但是这个转换有时会出错,比如中文字符有换行符时。

解决方法

那么怎么消除掉这个警告呢?

1.在git上配置

通过设置core.autocrlf属性 ,默认情况下core.autocrlf = true,要消除警告,我们把core.autocrlf属性设置为false.

user@IT00013733 MINGW64 ~/works (master)
$ git config core.autocrlf false
//设置 core.autocrlf = false

user@IT00013733 MINGW64 ~/works (master)
$ git config --get core.autocrlf
false
//查看该属性值
2.在IDE开发环境中进行配置

通过File->Line Separators将其换行格式指定为LF。
Git中“ LF will be replaced by CRLF in... ”警告解决方法_第1张图片

你可能感兴趣的:(Git中“ LF will be replaced by CRLF in... ”警告解决方法)