导航

git bash换行设置(Redirect)

Uinx/Linux采用换行符LF表示下一行(LF:Line Feed,中文意思是换行);"\r\n"
Dos和Windows采用回车+换行CRLF表示下一行(CRLF:Carriage Return Line Feed,中文意思是回车换行);"\r"
Mac OS采用回车CR表示下一行(CR:CarriageReturn,中文意思是回车)。
 
在Window里编辑的文档,使用换行CRLF,也就是文本中看到的^M;
git处理文件时,会提示用CRLF替换LF,这不是我们期待看到的;
# 关闭自动转换,文本保持原来的样子
git config --global core.autocrlf false

# 开启自动转换,add时将CRLF转为LF;checkout时将LF转为CRLF
git config --global core.autocrlf true

# add时将CRLF转为LF;checkout时为LF
git config --global core.autocrlf input

 

# git diff时忽略^M差异
git config --global core.whitespace cr-at-eol

 

 

posted on 2022-04-20 17:57  toughcactus  阅读(896)  评论(0编辑  收藏  举报