Day073 — LF and CRLF
1 min readMay 2, 2019
When developing a project in both Windows and Mac, one thing you should be aware of is line ending. Windows uses CRLF (\r\n), while Mac uses LF (\n). Platforms have their own default line ending. When you switch between platforms, the Git client shows all files as modified but the contents are the same. Therefore, a unified line ending should be used for a cross-platform project. You can either config that through command line or do that in the installation process of Git.
$ git config --global core.autocrlf input
$ git config --global core.safecrlf true
options for autocrlf
true: 提交时转换为 LF,检出时转换为 CRLF
false: 提交检出均不转换
input: 提交时转换为LF,检出时不转换
options for safecrlf
true: 拒绝提交包含混合换行符的文件
false: 允许提交包含混合换行符的文件
warn: 提交包含混合换行符的文件时给出警告
reference: