Question:
If I understand correctly, then in windows with autocrlf = true
, Git will convert CRLF
-> LF
after commit, and LF
-> CRLF
when checkout.
There are cases in my workflow where source files are manually dumped, bypassing the repository, from the working directory of the repository on the first Linux/Windows machine to the working directory of the second Windows machine.
At the same time, in these source files, the lines contain the LF
-ending, and in the working directory of the second machine, CRLF
. Does this mean that you will have to manually convert them to CRLF
with third-party software?
How to properly set up core.autocrlf
on both workstations to avoid errors during "manual" transfer of files?
I guess on Windows it's autocrlf = true
, and on Linux it's autocrlf = input
(to prevent the case above, only with CRLF
).
Answer:
I tested all the options and this is what happened:
╔═══════════════╦══════════════╦══════════════╦══════════════╗
║ core.autocrlf ║ false ║ input ║ true ║
╠═══════════════╬══════════════╬══════════════╬══════════════╣
║ git commit ║ LF => LF ║ LF => LF ║ LF => CRLF ║
║ ║ CR => CR ║ CR => CR ║ CR => CR ║
║ ║ CRLF => CRLF ║ CRLF => LF ║ CRLF => CRLF ║
╠═══════════════╬══════════════╬══════════════╬══════════════╣
║ git checkout ║ LF => LF ║ LF => LF ║ LF => CRLF ║
║ ║ CR => CR ║ CR => CR ║ CR => CR ║
║ ║ CRLF => CRLF ║ CRLF => CRLF ║ CRLF => CRLF ║
╚═══════════════╩══════════════╩══════════════╩══════════════╝
I think that the best option on all systems core.autocrlf = input
. At the same time, on all operating systems, CRLF
line endings will be implicitly converted to LF
if necessary, if there is already LF
, then it will remain so.