LF will be replaced by CRLF in git -the file will have its original line endings

十年热恋 提交于 2019-12-11 02:28:07

问题


LF will be replaced by CRLF in git -the file will have its original line endings what does this mean?


回答1:


This usually happens when you are on Windows and either core.autocrlf is set to true, or the .gitattributes contains directives to perform line ending normalizations.

The way line ending normalization works (on a Windows machine) is that when you commit a file, git replaces every CRLF with a LF, and when you checkout a file, git replaces every LF with a CRLF. Normally this is all transparent to you, and all you ever see is CRLFs in your working directory. However, if you somehow create a file with just LFs in your working directory, here is what will happen:

  1. When committing, git will "convert" the LFs to LFs, i.e. do nothing
  2. When checking out, git will convert the LFs to CRLFs

The upshot is, you end up creating a file with just LFs, but from then on you always see CRLFs in it. That is what git is warning you about.

Assuming that it is a text file we are talking about, you can go ahead and ignore this warning. However, if it is a binary file, it means that git is going to attempt to do line normalizations on it, which will corrupt the file. In that case you need to check your .gitattributes file and see why this is happening.



来源:https://stackoverflow.com/questions/30523236/lf-will-be-replaced-by-crlf-in-git-the-file-will-have-its-original-line-endings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!