git 中遇到CRLF/LF warning

在Windows下使用git時遇到如下的提示:

 

warning: LF will be replaced by CRLF in a.txt.
The file will have its original line endings in your working directory.

 

引起warning的原因是:

git本是Linux下的tool, 在Linux下文本中的換行符爲LF.

而在Windows下的則是回車換行CRLF(carriage return/line feed)

所以git在Windows下輸出時會出現LF will be replaced by CRLF, 所謂入鄉隨俗

 

解決方法:

git中有針對此換行符的設置core.autocrlf, 在Windows下使用git時把它設置爲false就不會再出現warning

git config --global core.autocrlf false

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章