2009-07-30 64 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