欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

windows使用git时出现:warning: LF will be replaced by CRLF的解决办法 | Avalon

 

 

在Windows环境下使用git进行add的时候,会提示如下warning: “warning:LF will be replacee by CRLF”。

这是因为在Windows中的换行符为CRLF,而在Linux中的换行符为LF。在git创建的项目中换行符为LF,而执行git add时,系统会提示LF将被转换为CRLF。解决的办法很简单,禁止git的自动转换即可。


1$ git config --global core.autocrlf false //禁用自动转换

然后再进行git操作即可。
如果项目已经创建,则需要先删除之前创建的.git 文件后添加上面的设置。


1
2
$ rm -rf .git
$ git config --global core.autocrlf false

完成后再重新执行git操作


1
2
3
$ git init
$ git add .
$ git remote add ***

P.S.

CRLF : Carriage-Return Line-Feed 回车换行。即回车(CR,ASCII 13, \r)换行(LF, ASCII 10, \n).
在windows中使用回车换行标识一行的结束,而Linux中则只有换行符。

来自 http://www.360doc.com/content/17/0327/17/13518188_640596576.shtml

git 转换 换行符(回车) 在提交时自动地把行结束符CRLF转换成LF,而在签出代码时把LF转换成CRLF
        git config --global core.autocrlf true
在提交时把CRLF转换成LF,签出时不转换

     git config --global core.autocrlf input
把回车符记录在库中       
  git config --global core.autocrlf false

来自  http://www.360doc.com/content/16/0226/16/7991404_537579445.shtml

 

/README.txt: UTF-8 Unicode (with BOM) English text, with CRLF line terminators


 

I have been working on a Drupal.org project and I want to make sure that pass all the coding standards. For some reason I got these problem with the README.txt encoding and I dont know how to solve it.

 ./README.txt: UTF-8 Unicode (with BOM) English text, with CRLF line terminators README.txt
  • Bad line endings were found, always use unix style terminators
  • ./README.txt: the byte order mark at the beginning of UTF-8 files is discouraged, you should remove it.

Can anyone tell me how to solve this problem ? I'm currently using Sublime Text 2 and I save my README.txt as UTF-8 Unicode with BOM and this did not fix my problem.

Here is the README.txt https://gist.github.com/darol100/e24059dbacc4f7e205adhttp://pareview.sh/pareview/httpgitdrupalorgsandboxdarol1002309319git

    正确答案 

In Settings - User config, you should set

"default_line_ending": "unix",

Also, when saving file, select UTF-8 Unicode without BOM - that's exactly what you were told here:

the b​yte o​rder m​ark at the beginning of UTF-8 files is discouraged

Emphasis mine.

Taken from Fixing Sublime Text 2 line endings?

shareimprove this answer

来自  http://drupal.stackexchange.com/questions/128673/readme-txt-utf-8-unicode-with-bom-english-text-with...
普通分类: