在一台Windows机器上,我使用git add添加了一些文件。 我收到警告说:
LF将被CRLF取代
这种转变的后果是什么?
在一台Windows机器上,我使用git add添加了一些文件。 我收到警告说:
LF将被CRLF取代
这种转变的后果是什么?
当前回答
我也有同样的问题,做git添加。&& git重置恢复所有行结束正确。
其他回答
从~/。gitattributes文件,
* text = auto
将防止Git首先检查行结束符。
在GNU/Linux shell提示符中,dos2unix和unix2dos命令允许您轻松地转换/格式化来自MS Windows的文件。
我也有这个问题。
SVN不执行任何行结束转换,因此提交文件时保留CRLF行结束。如果您使用git-svn将项目放入git中,那么CRLF结束符将持续到git存储库中,这不是git希望自己处于的状态——默认情况是只检入unix/linux (LF)行结束符。
当您在windows上签出文件时,selflf转换会保持文件不变(因为它们已经具有当前平台的正确结尾),但是,决定签入文件是否存在差异的进程会在比较之前执行反向转换,从而将它认为是签出文件中的LF与存储库中的意外CRLF进行比较。
在我看来,你的选择是
Re-import your code into a new git repository without using git-svn, this will mean line endings are converted in the intial git commit --all Set autocrlf to false, and ignore the fact that the line endings are not in git's preferred style Check out your files with autocrlf off, fix all the line endings, check everything back in, and turn it back on again. Rewrite your repository's history so that the original commit no longer contains the CRLF that git wasn't expecting. (The usual caveats about history rewriting apply)
注:如果你选择选项2,那么我的经验是,一些辅助工具(rebase, patch等)不能处理CRLF文件,你迟早会得到混合了CRLF和LF(不一致的行尾)的文件。我不知道有什么办法能两全其美。
我也有同样的问题,做git添加。&& git重置恢复所有行结束正确。
我只是犯了同样的错误。 这是在Windows 10上安装NVM NVM后发生的。
在所有级别设置autoclrf都不起作用。
在CMD中我使用:“git ls-files——eol”
i/lf w/crlf attr/ src/components/quotes/ExQuoteForm.js
i/lf w/lf attr/ src/components/quotes/HighlightedQuote.js
结论:
我做的文件有不同的结局。
要更改文件和重置,请执行
git config core.autocrlf false
git rm --cached -r .
git reset --hard
尽管:
在一些项目中,我需要删除存储库并重新启动它。