2012-09-20 116 views
4

我使用git-gui進行版本控制並將它們推送到遠程位置。當我嘗試重新掃描文件以進行更改時,我收到了此消息,但我不確定這意味着什麼。請幫我在這裏。更新Git索引失敗,LF將被CRLF替換?

enter image description here

Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui. 

warning: LF will be replaced by CRLF in bin/jarlist.cache. 
The file will have its original line endings in your working directory. 
warning: LF will be replaced by CRLF in gen/com/click4tab/pustakalpha/BuildConfig.java. 
The file will have its original line endings in your working directory. 
warning: LF will be replaced by CRLF in proguard-project.txt. 
The file will have its original line endings in your working directory. 
warning: LF will be replaced by CRLF in project.properties. 
The file will have its original line endings in your working directory. 
warning: LF will be replaced by CRLF in res/layout/start_test.xml. 
The file will have its original line endings in your working directory. 
warning: LF will be replaced by CRLF in res/menu/start_test.xml. 
The file will have its original line endings in your working directory. 
warning: LF will be replaced by CRLF in src/com/click4tab/pustakalpha/StartTestActivity.java. 
The file will have its original line endings in your working directory. 
+0

可能重複(http://stackoverflow.com/questions/10573815/why-is-updating -git-index-failed-displayed) –

回答

-1

這行代碼應該避免這樣的警告:

git config core.autocrlf false 

如果您想更詳細的答案,你如何以及在何處進入該行的代碼,看看這裏: https://stackoverflow.com/questions/3841140/git-how-to-get-rid-of-the-annoying-crlf-message-on-msysgit-windows

+2

糟糕的建議,需要'autocrlf'來保持跨平臺一致的提交行結束。你有沒有嘗試解決衝突,只有幾條線實際上發生了變化,但它們隱藏在線端「變化」的海洋中? – Walf

2

解決方法是接受該行爲。你在Windows上,所以你應該autocrlf作爲true。它在那裏,所以Git內部記錄中的行結束是一致的。警告在那裏,所以你可以看到你是否即將在提交期間意外地破壞二進制文件。

點擊繼續。如果你想防止它再次發生在這些文件上,你需要取消這些文件,然後糾正行結束並再次分階段。通過在編輯器中將文件的行結束符更改爲CRLF/Windows,或將these command line tools放入您的system32目錄中,以便您可以在任何命令提示符下對此類文件執行unix2dos some_file.java

1

我面臨類似的問題,並決定仔細看看我的配置。

Windows/Linux上/ MAC換行符:

  1. MAC OS X之前:\ r = CR(回車)
  2. MAC OS X/UNIX:\ n = LF(換行)
  3. 視窗:\ r \ n = CR + LF

不要驚慌。 Git可以爲你處理平臺之間的轉換。

Git應該在回購中存儲以LF結尾的行。

將其設置爲;

TRUE - 如果你使用的是Windows

git config --global core.autocrlf true 

這LF結局轉換成CRLF,當你看看代碼。

輸入 - 如果你是一個MAC/LINUX

你不需要任何轉換,Git使用LF和你的MAC使用LF。

但是,你可以告訴git的任何CRLF轉換,如果一個經過:

git config --global core.autocrlf input 

假 - 不recommened

我並不推薦這樣做,但只是爲了這個緣故解釋:

如果你是一個windows開發者,只能在windows機器上工作,並且你100%確定你永遠不會和MAC上的人一起工作:

git config --global core.autocrlf false 

UPDATE:

如下評論,我沒有提到的.gitattributes其中一個可以預設這些設置的一個項目。

如果havetime,這裏是DOC:http://git-scm.com/docs/gitattributes

[顯示爲什麼是 '更新的Git指標不合格']的
+0

爲什麼不直接檢查'.gitattributes'文件而不是100%確定?那樣,不是每個人都必須配置一些神祕的東西。 –

+0

我不認爲「.gitattributes」會告訴你誰是你的同事,以及你是否一個人在一個項目上工作。在回答這樣的答案之前,請先閱讀兩個句子。請記住,人們在這裏幫助或應該。 – andrew

+0

不,'.gitattributes'會告訴大家在同一個項目上工作如何處理行尾,而不是試圖確保每個人都有相同的配置設置。使用'.gitattributes',不要使用'core.autocrlf'。 –