How to handle cross platform line endings in git

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By kmcphillips

We are using git (github) to collaborate between Windows, Mac, and Linux machines on the same project.

We are having issues with the editor saving files automatically and having most of the project show as dirty, converting CR to CRLF and vice versa. Meaning that for example: Godot Linux opens a file last edited on Windows, saves it by changing all the line endings, then git shows that and other files as modified.

I know this is a git question as much as a Godot question. But since the editor forces native line endings rather than having it be configurable, I have not figured out how to mitigate it. I have tried using a .gitattributes and *.tscn text but have not been successful:

There is an existing feature request issue to make this setting configurable, but has received little attention. I looked at it but my C++ is not nearly strong enough to make a contribution of this magnitude:

Does it work better if you use *.tscn text eol=lf in .gitattributes? Godot (and most other software) can handle files with LF line endings just fine on Windows.

You may also want to disable automatic line ending conversion when cloning repositories using git config --global core.autocrlf input. This will only convert line endings from CRLF to LF (in case of mistakes) when committing files, not when cloning them.

Calinou | 2019-05-21 17:38