windowslinuxgitnewlinecore.autocrlf

Git on Windows: What do the crlf settings mean?


I don't understand the complexities related to CrLf settings in git: core.autocrlf, core.safecrlf

I'm developing a cross-platform project in a team and would like both Windows and Linux developers to be able to work together without git marking files as modified just because of line ending style.

What do the various settings mean? What would be the consequences of choosing any of the options? And what would be the best solution for my case?

Yes, I'm aware of this question and the answers there were not insightful, thus not helpful.


Solution

  • The three values for autocrlf:

    Note that autocrlf will not affect content which is already in the repository. If you've committed something with CRLF endings previously, they'll stay that way. This is a very good reason to avoid depending on autocrlf; if one user doesn't have it set, they can get content with CRLF endings into the repo, and it'll stick around. A stronger way to force normalization is with the text attribute; setting it to auto for a given path will mark it for end-of-line normalization, assuming git decides the content is text (not binary).

    A related option is safecrlf, which is basically just a way to make sure you don't irreversably perform CRLF conversion on a binary file.

    I don't have a ton of experience dealing with Windows issues and git, so feedback about implications/pitfalls is certainly welcome.