env:
视窗 7 麦克西吉特
当我提交时,它说:
warning: LF will be replaced by CRLF.
这个警告尾巴是向后的吗? 我在Windows中编辑文件,行尾是CRLF,就像这张图片: git将其更改为LF,用于提交回购。 所以我认为正确的警告是:
warning: CRLF will be replaced by LF.
env:
视窗 7 麦克西吉特
当我提交时,它说:
warning: LF will be replaced by CRLF.
这个警告尾巴是向后的吗? 我在Windows中编辑文件,行尾是CRLF,就像这张图片: git将其更改为LF,用于提交回购。 所以我认为正确的警告是:
warning: CRLF will be replaced by LF.
当前回答
我遇到过类似的问题,在windows上使用vscode(v1.57)尝试了其他答案中定义的解决方案,但没有工作。
所以对我来说,以下步骤是有效的:
在根文件夹中有一个名为.editorconfig的文件 打开该文件,将end_of_line = lf修改为end_of_line = CRLF 运行git rm——缓存,警告消失!!
其他回答
在我设定核心之后。我得到了“LF将被CRLF取代”(注意不是“CRLF将被LF取代”)当我在git添加(或者可能是它在git提交?)编辑文件在窗口上的存储库(使用LF),在我设置core. selflf =true之前签出。
我用core做了一个新的结账。selflf =true,现在我没有得到这些消息。
做一些简单的事情:
打开git-hub (Shell)并导航到目录文件属于(cd /a/b/c/…) 执行dos2unix(有时是dos2unix.exe) 试着现在就承诺。 如果你再次得到相同的错误。 执行以上所有步骤,除了不执行dos2unix,而是执行unix2dox(有时使用unix2dos.exe)
这个警告尾巴是向后的吗?
这一警告首先令人困惑。 Git 2.37 (Q3 2022)对其进行了改写和澄清。
参见Alex Henrie (alexhenrie)提交c970d30 (07 Apr 2022)。 (由Junio C Hamano—gitster—在提交0a88638中合并,2022年5月20日)
转换:澄清行结束转换警告 署名:Alex Henrie
The warning about converting line endings is extremely confusing. LF will be replaced by CRLF in ... The file will have its original line endings in your working directory. Its two sentences each use the word "will" without specifying a timeframe, which makes it sound like both sentences are referring to the same timeframe. On top of that, it uses the term "original line endings" without saying whether "original" means LF or CRLF. Rephrase the warning to be clear about when the line endings will be changed and what they will be changed to.
在本机行结束符不是CRLF的平台上(例如Linux),以下顺序中的“git add”(man)步骤会触发有问题的新消息(不再有警告):
$ git config core.autocrlf true
$ echo 'Hello world!' >hello.txt
$ git add hello.txt
In the working copy of 'hello.txt', CRLF will be replaced by LF
the next time Git touches it.
在本机行结束符不是LF的平台上(例如Windows),下面序列中的“git add”(man)步骤会触发有问题的新消息(不再有警告):
$ git config core.autocrlf true
$ echo 'Hello world!' >hello.txt
$ git add hello.txt
In the working copy of 'hello.txt', LF will be replaced by CRLF
the next time Git touches it.
所有这些都假设core. selflf =true
原始错误:
警告:LF将被CRLF取代 该文件在您的工作目录中有其原始的行结束符。
错误应该是什么:
警告:在你的工作目录中,LF将被CRLF取代 文件将在git存储库中有其原始的LF行结束符
解释:
The side-effect of this convenient conversion, and this is what the warning you're seeing is about, is that if a text file you authored originally had LF endings instead of CRLF, it will be stored with LF as usual, but when checked out later it will have CRLF endings. For normal text files this is usually just fine. The warning is a "for your information" in this case, but in case git incorrectly assesses a binary file to be a text file, it is an important warning because git would then be corrupting your binary file.
基本上,以前是LF的本地文件现在在本地具有CRLF
这是因为Windows上的GitHub Desktop的配置假设CRLF,但文本编辑器可能使用LF。您可以将本地存储库设置改为使用lf。
导航到git repo的根目录,并以完全相同的顺序执行
git config core.eol lf
git config core.autocrlf input
来源:GitHub问题