使用git add时提示warning: LF will be replaced by CRLF

科普

符号 解释
CR Carriage Return (ASCII 13, \r)
LF Line Feed (ASCII 10, \n)

  CRLF(即\r\n)和LF(即\n)都是换行符。一般来说windows使用CRLF,而linux使用LF。但实际上这和所使用的文本编辑器有关,部分文本编辑器可以选择换行风格。

解释和操作

解释

  简单的说,这个警告发生于

  1. 使用windows上的git
  2. 你的文本编辑器使用了LF作为换行符
  3. git add的检查阶段(checkout)而非提交阶段(commit)
  4. core.autocrlf=true

操作

  实际上这个替换是没有必要的,因此可以将core.autocrlf=true设置为false,命令行键入

git config --global core.autocrlf false

参考

  github相关的issue

  stackoverflow:Windows git “warning: LF will be replaced by CRLF”, is that warning tail backward?

  stackoverflow: git replacing LF with CRLF

猜你喜欢

转载自blog.csdn.net/qq_34769162/article/details/108510229