2009-07-30 63 views
4

我和我的同事們在git與我們的Windows reposti克隆上的某些文件正常運行時遇到了很大的麻煩。克隆是通過克隆源自OSX機器的存儲庫而製作的。我們已經將autocrlf設置爲true,但問題是,我們經常找到git認爲改變的文件,即使我們從未觸摸它們(我們甚至不在編輯器中打開它們)。處理Git拒絕重置的文件?

以下輸出說明了此問題:任何想法我要去的地方錯了?

$ git status                         
# On branch master                       
# Your branch is behind 'origin/master' by 27 commits, and can be fast-forwarded.        
#                            
# Changed but not updated:                     
# (use "git add <file>..." to update what will be committed)            
# (use "git checkout -- <file>..." to discard changes in working directory)         
#                            
#  modified: Web Applications/webclient/language/en/lang_copyitems.ini         
#                            
no changes added to commit (use "git add" and/or "git commit -a")            

[email protected] ~/Documents/Workspace/prestige.git             
$ git diff "Web Applications/webclient/language/en/lang_copyitems.ini"          
diff --git a/Web Applications/webclient/language/en/lang_copyitems.ini b/Web Applications/webclient/language/ 
index 800c188..ed11c0e 100644                     
--- a/Web Applications/webclient/language/en/lang_copyitems.ini            
+++ b/Web Applications/webclient/language/en/lang_copyitems.ini            
@@ -1,12 +1,12 @@                        
-<EF><BB><BF> [Header]                      
-  Description=Language strings for 'copyitems.php'              
-                            
-  [Messages]                       
-  300=Copy                        
-  301=Close                        
-  302=COPY STORIES                      
-  303=Name                        
-  304=In Queue                       
-  305=New Name                       
-  306=Items to Copy                      
-  308=This item has mandatory metadata fields that are not correctly set. Click any part of this messag 
+<EF><BB><BF> [Header]                      
+  Description=Language strings for 'copyitems.php'              
+                            
+  [Messages]                       
+  300=Copy                        
+  301=Close                        
+  302=COPY STORIES                      
+  303=Name                        
+  304=In Queue                       
+  305=New Name                       
+  306=Items to Copy                      
+  308=This item has mandatory metadata fields that are not correctly set. Click any part of this messag 

[email protected] ~/Documents/Workspace/prestige.git             
$ git checkout HEAD "Web Applications/webclient/language/en/lang_copyitems.ini"        

[email protected] ~/Documents/Workspace/prestige.git             
$ git status                         
# On branch master                       
# Your branch is behind 'origin/master' by 27 commits, and can be fast-forwarded.        
#                            
# Changed but not updated:                     
# (use "git add <file>..." to update what will be committed)            
# (use "git checkout -- <file>..." to discard changes in working directory)         
#                            
#  modified: Web Applications/webclient/language/en/lang_copyitems.ini         
# 

回答

6

的問題與此設置,由GitHub guide所示是一個自動轉換的結賬庫的期間完成...

這意味着你不需要打開一個fi觸發任何變化。

是不是可以保持autocrlf爲false,並在編輯器中打開那些能夠尊重返回行字符的Windows文件?

注(illustrated here),如果你需要轉換,除了一些文件,你可以在父目錄中添加一個.gitattributes,具有:

myFile -crlf 

在您設置屬性的路徑文件(或一個模式),或取消它們(帶有減號)。
crlf屬性是指示文件是否受core.autocrlf選項影響的屬性。如果你沒有設置它,Git不會混淆文件中的行結尾

+0

您從Github發佈的好鏈接。因此,解決方案是一次性提交這些文件,從此以後一切都會好起來。感謝指針。 – jkp 2009-07-30 14:01:01

1

要使用git 1.7.3.1在我的Windows 7機器上解決這個問題,我必須將core.filemode選項設置爲false。

git config -e --local 
+0

謝謝你。用年齡結束標誌的行尾。更改.git/config中的core.filemode工作正常。 – griffin2000 2017-05-31 20:27:38