一、不同操系統下的換行符
CR回車 LF換行
Windows/Dos CRLF \r\n
Linux/Unix LF \n
MacOS CR \r
二、解決方法
打卡git bash,設置core.autocrlf和core.safecrlf(可不設置),建議設置autocrlf為input,safecrlf為true,同時設置你的Eclipse、IDEA等IDE的換行符為LF\n。
下面為參數說明,--global表示全局設置
2.1、autocrlf
#提交時轉換為LF,檢出時轉換為CRLF
git config --global core.autocrlf true
#提交時轉換為LF,檢出時不轉換
git config --global core.autocrlf input
#提交檢出均不轉換
git config --global core.autocrlf false
2.2、safecrlf
#拒絕提交包含混合換行符的文件
git config --global core.safecrlf true
#允許提交包含混合換行符的文件
git config --global core.safecrlf false
#提交包含混合換行符的文件時給出警告
git config --global core.safecrlf warn