CRLF -- Carriage-Return Line-Feed 回车换行
一、CRLF的意思
在Git通过下面的命令配置
$git config --global core.autocrlf true
# Configure Git on Windows to properly handle line endings
解释:core.autocrlf是git中负责处理line endings的变量,可以设置三个值--true,inout,false.
设置成三个值会有什么效果呢?
If core.autocrlf
is set to true, that means that any time you add a file to the git repo that git thinks is a text file, it will turn all CRLF line endings to just LF before it stores it in the commit.。
设置为true,添加文件到git仓库时,git将其视为文本文件。他将把crlf变成lf。【2】
If core.autocrlf
is set to false, no line-ending conversion is ever performed, so text files are checked in as-is. This usually works ok。【2】
设置为false时,line-endings将不做转换操作。文本文件保持原来的样子。
设置为input时,添加文件git仓库石,git把crlf编程lf。当有人Check代码时还是lf方式。因此在window操作系统下,不要使用这个设置。
这是参考文献2给的解释希望能帮助大家。
Yet another way to show how autocrlf
works
1) true: x -> LF -> CRLF
2) input: x -> LF -> LF
3) false: x -> x -> x
where x is either CRLF (windows-style) or LF (unix-style) and arrows stand for
file to commit -> repository -> checked out file