2012-09-09 45 views
6

根據this question,我知道core.autocrlf = true在git中會導致CRLF到LF的轉換。做一個git倉庫有core.autocrlf它自己的本地值覆蓋全球嗎?

然而,當我鍵入: 混帳配置core.autocrlf

我看到: 假

然而,當我修改階段的文件中已有的回購,我仍然得到這些警告:

Warning: CRLF will be replaced by LF in File1.X. 
The file will have its original line endings in your working directory. 

我的猜測是該文件的回購副本已經設置爲「autocrlf = true」。

問題:A.如何查詢文件或git倉庫是否已經強制AutoCrlf? B.如何關閉autocrlf?

回答

6

Git允許您使用.gitattributes文件基於每個存儲庫覆蓋您的全局設置。您將其放入存儲庫的根目錄中,併成爲作爲存儲庫一部分提交的文件。我懷疑你的情況正在發生。

Github上有一個很好的頁面:https://help.github.com/articles/dealing-with-line-endings

總之,你可以使用文本屬性設置行尾爲特定文件擴展名。例如,迫使SLN文件CRLF將需要在.gitattributes文件以下行:

# Declare files that will always have CRLF line endings on checkout. 
*.sln text eol=crlf 
+1

右...所以...我會放在'.gitattributes'這將是'核心相當於.autocrlf = false'在我的全局配置? –

+0

那麼'.gitattributes'中的以下內容將等同於'core.autocrlf = false'? '* -text' –

+0

如果刪除二進制文件,則.gitattributes也會影響合併能力。 – jhclark

相關問題