解決不一樣操做系統下git換行符一致性問題

1、不一樣操系統下的換行符
CR回車 LF換行
Windows/Dos CRLF \r\n
Linux/Unix LF \n
MacOS CR \r
2、解決方法git

打卡git bash,設置core.autocrlf和core.safecrlf(可不設置),建議設置autocrlf爲input,safecrlf爲true,同時設置你的Eclipse、IDEA等IDE的換行符爲LF\n。
下面爲參數說明,--global表示全局設置bash

2.一、autocrlfspa

#提交時轉換爲LF,檢出時轉換爲CRLF
git config --global core.autocrlf true ip

#提交時轉換爲LF,檢出時不轉換
git config --global core.autocrlf input input

#提交檢出均不轉換
git config --global core.autocrlf falseit

2.二、safecrlfcli

#拒絕提交包含混合換行符的文件
git config --global core.safecrlf true 方法

#容許提交包含混合換行符的文件
git config --global core.safecrlf false 文件

#提交包含混合換行符的文件時給出警告
git config --global core.safecrlf warnco

相關文章
相關標籤/搜索