git config --global core.autocrlf input
根据github的帮助页面,这应该配置git在提交时将所有行结束符转换为LF。
但是当我提交到我的repo时,会得到以下输出。
> git commit -am "test commit"
warning: LF will be replaced by CRLF in .htaccess.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in .htaccess.
The file will have its original line endings in your working directory.
[release/4.2 27bad5b] test commit
warning: LF will be replaced by CRLF in .htaccess.
The file will have its original line endings in your working directory.
1 files changed, 1 insertions(+), 1 deletions(-)
我随后检查了我的配置文件,以确定autocrlf选项是否正确设置,并且它是正确的。
> git config -l | grep "crlf"
core.autocrlf=input
为什么git会将我的LF转换为CRLF而不是我想要的反向转换呢?它为什么会发出3次警告?是因为它发现了3个需要替换的实例吗?为什么在输出提交哈希后只警告我一次呢?我很困惑(记录一下,我正在使用Mac)