处理Git拒绝重置的文件?

我和我的同事们在使用我们的Windows repostiory克隆上的某些文件的同时,让git行为正常,遇到了很大的麻烦。 克隆已经通过克隆源自OSX机器的存储库来完成。 我们已经将autocrlf设置为true,但问题是我们经常会发现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") Administrator@windows-dev ~/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 Administrator@windows-dev ~/Documents/Workspace/prestige.git $ git checkout HEAD "Web Applications/webclient/language/en/lang_copyitems.ini" Administrator@windows-dev ~/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 # 

Solutions Collecting From Web of "处理Git拒绝重置的文件?"

这个设置的问题,如GitHub指南所示,是一个自动转换在出库的过程中完成的。

这意味着您不需要打开文件来触发任何更改。

是不是可以保持autocrlf为false,并在编辑器中打开那些能够尊重返回行字符的Windows文件?

注意( 如图所示 ),如果你需要转换,除了一些文件,你可以在父目录中添加一个.gitattributes,用:

 myFile -crlf 

在文件中,您将属性设置为一个路径(或一个模式),或取消设置(使用减号)。
crlf属性是core.autocrlf文件是否受core.autocrlf选项影响的core.autocrlf 。 如果你没有设置,Git不会混淆文件中的行结尾

要使用git 1.7.3.1在我的Windows 7机器上解决这个问题,我必须将core.filemode选项设置为false。

 git config -e --local