2011-06-22 91 views
7

git config --global core.autocrlf inputgit autocrlf輸入確實會轉換行尾,但是從LF到CRLF?

根據this github help page所以將所有行結束時提交到LF這應該配置的git。

然而,當提交到我的回購這是我得到的輸出。

> 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個將被替換的事件?爲什麼它會在輸出commithash之後警告我一次呢?

我很困惑(和MAC備案:)上)

+0

(注意,github頁面僅在非windows標籤中提到了「autocrlf = input」...) – rogerdpack

回答

13

經過漫長的時間處理行結束,我根本不會允許任何工具,包括VCS改變他們在我身上。

我現在使用autocrlf falsecore.whitespace cr-at-eol。這消除了差異輸出中令人討厭的^ M。這只是一個突出的補充,git的確可以讓你看到諸如行末或額外空格之類的令人毛骨悚然的東西,等等。

希望你也可以做同樣的事, 。

+0

Adam的建議值得商榷。使用包含混合行結尾的傳統Intranet內容在某些文件(這是啓動autocrlf時)初始化大型回購時遇到類似問題。關閉autocrlf是最激動人心的行動方式。 – Blackcoat

相關問題