What's the best CRLF (carriage return, line feed) handling strategy with Git?

后端 未结 9 1979
青春惊慌失措
青春惊慌失措 2020-11-22 07:30

I tried committing files with CRLF-ending lines, but it failed.

I spent a whole work day on my Windows computer trying different strategies and was almost drawn to s

9条回答
  •  星月不相逢
    2020-11-22 08:13

    You almost always want autocrlf=input unless you really know what you are doing.

    Some additional context below:

    It should be either core.autocrlf=true if you like DOS ending or core.autocrlf=input if you prefer unix-newlines. In both cases, your Git repository will have only LF, which is the Right Thing. The only argument for core.autocrlf=false was that automatic heuristic may incorrectly detect some binary as text and then your tile will be corrupted. So, core.safecrlf option was introduced to warn a user if a irreversable change happens. In fact, there are two possibilities of irreversable changes -- mixed line-ending in text file, in this normalization is desirable, so this warning can be ignored, or (very unlikely) that Git incorrectly detected your binary file as text. Then you need to use attributes to tell Git that this file is binary.

    The above paragraph was originally pulled from a thread on gmane.org, but it has since gone down.

提交回复
热议问题