git 下处理换行问题
配置方法
在所有的 git 全局配置中,配置:
# Configure Git to ensure line endings in files you checkout are correct for macOS
git config --global core.autocrlf input
或者在对应的 ~/.gitconfig 中配置:
[core]
autocrlf = input
但是 github 推荐在 windows 中将这个选项设置为 true,我查了下觉得在三端均采用 input 是非常合理的。
配置说明
| 配置值 | 含义 |
|---|---|
| true | 双向转换: • 输入(commit)时:CRLF → LF • 输出(checkout)时:LF → CRLF |
| input | 仅输入时转换: • 输入(commit)时:CRLF → LF • 输出(checkout)时:不做转换(保留 LF) |
| false | 完全不转换 |