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

问题

在命令行执行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 . 

相关文章

文章浏览阅读2.2k次,点赞6次,收藏20次。在我们平时办公工作...
文章浏览阅读1k次。解决 Windows make command not found 和...
文章浏览阅读3.2k次,点赞2次,收藏6次。2、鼠标依次点击“计...
文章浏览阅读1.3w次。蓝光版属于高清版的一种。BD英文全名是...
文章浏览阅读974次,点赞7次,收藏8次。提供了更强大的功能,...
文章浏览阅读1.4w次,点赞5次,收藏22次。如果使用iterator的...