env:

视窗 7 麦克西吉特

当我提交时,它说:

warning: LF will be replaced by CRLF. 

这个警告尾巴是向后的吗? 我在Windows中编辑文件,行尾是CRLF,就像这张图片: git将其更改为LF,用于提交回购。 所以我认为正确的警告是:

warning: CRLF will be replaced by LF. 

当前回答

这个警告尾巴是向后的吗?

这一警告首先令人困惑。 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.

其他回答

在我设定核心之后。我得到了“LF将被CRLF取代”(注意不是“CRLF将被LF取代”)当我在git添加(或者可能是它在git提交?)编辑文件在窗口上的存储库(使用LF),在我设置core. selflf =true之前签出。

我用core做了一个新的结账。selflf =true,现在我没有得到这些消息。

是的,警告是反的。

事实上,它一开始就不应该是一个警告。因为所有这些警告都在说(但不幸的是倒着说),你文件中带有Windows行结束符的CRLF字符将在提交时被LF字符替换。这意味着它被标准化为*nix和MacOS使用的相同的行结束符。

没有什么奇怪的事情发生,这正是你通常想要的行为。

当前形式的警告是以下两件事之一:

一个不幸的漏洞加上一个过于谨慎的警告信息, 或 一个非常聪明的情节,让你真正思考这个问题……

;)

这个警告尾巴是向后的吗?

这一警告首先令人困惑。 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.

——7月9日更新——

删除了@mgiuca评论的“这是正确和准确的”

= = = = = =

不。它不是谈论您的文件当前与CRLF。而是用LF讨论文件。

它应该是:

警告:(如果你检出/或克隆到另一个文件夹与你当前的核心。自自配置,)LF将被CRLF取代 该文件将在您的(当前)工作目录中有其原始的行结束符。

这张图可以解释它的意思。

关闭Visual Studio

如果你得到这个错误,一个简单的解决方法是关闭Visual Studio,然后你可以提交到main,就是这么简单。 我也遇到过同样的问题,我就是这样解决的。这是因为您要打开的文件在另一个程序中打开了。