栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

【Cygwin64 Terminal】git 拉的代码提示:warning: LF will be replaced by CRLF

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【Cygwin64 Terminal】git 拉的代码提示:warning: LF will be replaced by CRLF

前言
  • 如今windows操作系统占用的内存越来越大,导致自己想自己开发【操作系统】。。。
  • windows下安装【VM虚拟机】开发基于Linux的工程,感觉电脑内存吃不消
  • windows下可以使用【Cygwin64 】解决一部分问题
Cygwin64 本身也是问题
  • Cygwin64 由于工作在windows上,环境还是有区别与:Linux
  • windows下的文件名称,不区分大小写,按时Linux文件名区分大小写
  • windows 下的回车换行问题,最终发现是git 配置与拉代码引起的
git 正确的配置
  • windows下的git 配置如下:
#提交时转换为LF,检出时转换为CRLF
$ git config --global core.autocrlf true
#提交时转换为LF,检出时不转换
$ git config --global core.autocrlf input
  • 为何这么配置呢?这里是windows、Linux混合开发的场景下,回车换行问题突出,Linux下是sh文件,如果被自动增加r,会造成各种异常的错误,无法正确的执行
问题如下
  • 一台电脑上,使用【Cygwin64】正常的 make menuconfig
  • 另一台电脑,git pull 代码后,发现各种错误,开始以为是Cygwin64没有安装全工具包,后面发现原来就是回车换行引起sh 文件无法正确运行引起的
$ git diff
warning: LF will be replaced by CRLF in .config.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in .config.old.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in .kconfig.d.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in include/autoconf.h.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in scripts/Kbuild.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in scripts/basic/.docproc.cmd.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in scripts/basic/.fixdep.cmd.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in scripts/basic/.split-include.cmd.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in scripts/gen_build_files.sh.
The file will have its original line endings in your working directory
  • 不要让 git 改变回车换行,也就是Linux 本身的回车换行,拉下来时 windows git 可以增加r,但是提交时,不需要增加r。
  • 以下大的错误,看似很多,就是 sh文件,被增加r引起的。
$ make menuconfig
  HOSTCC  scripts/kconfig/conf.o
  HOSTCC  scripts/kconfig/kxgettext.o
  SHIPPED scripts/kconfig/zconf.hash.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/mconf
/cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 3: $'r': command not found
/cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 5: syntax error near unexpected token `$'r''
'cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 5: `ldflags()
/cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 3: $'r': command not found
/cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 5: syntax error near unexpected token `$'r''
'cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 5: `ldflags()
/cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 3: $'r': command not found
/cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 5: syntax error near unexpected token `$'r''
'cygdrive/d/github/pluto-os_hello/scripts/kconfig/lxdialog/check-lxdialog.sh: line 5: `ldflags()
  HOSTCC  scripts/kconfig/lxdialog/checklist.o
In file included from scripts/kconfig/lxdialog/checklist.c:24:
scripts/kconfig/lxdialog/dialog.h:31:10: error: #include expects "FILENAME" or 
   31 | #include CURSES_LOC

小结
  • 正确理解 git CRLF的配置问题
  • 注意Linux、windows混合开发过程中git的配置引起的问题
  • 注意Linux sh 文件不允许增加额外的:r 的问题
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/695037.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号