侧边栏壁纸
  • 累计撰写 71 篇文章
  • 累计创建 87 个标签
  • 累计收到 5 条评论

目 录CONTENT

文章目录

windows下解决Git报错: LF will be replaced by CRLF the next time Git touches it

KunkkaWu
2022-10-11 / 0 评论 / 10 点赞 / 3,828 阅读 / 172 字 / 正在检测是否收录...

问题

在命令行执行git add .的时候,提示Warning

$ git add .
warning: in the working copy of 'go.mod', LF will be replaced by CRLF the next time Git touches it
warning: in the working copy of 'go.sum', LF will be replaced by CRLF the next time Git touches it

通常情况下是在 Windows环境中才会遇到。

原因

在windows中的换行符为 CRLF, 而在linux下的换行符为:LF
所以使用git来生成一个工程后,文件中的换行符为LF, 当执行git add .时,系统则提示:LF 将被转换成 CRLF

解决

关闭git的自动更换CRLF即可

$ rm -rf .git
$ git config --global core.autocrlf false 
$ git init
$ git add . 
10

评论区