处理Git拒绝重置的文件? [英] Dealing with files that Git refuses to reset?

查看:113
本文介绍了处理Git拒绝重置的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和我的同事们在使用我们的Windows repostiory克隆上的某些文件时,遇到 git >的问题,这很麻烦。克隆是通过克隆源自OSX机器的存储库而制作的。我们已经将autocrlf设置为true,但问题是我们经常会发现 git 认为会更改的文件,即使我们从未触摸它们(我们甚至不会在

下面的输出说明了这个问题:任何想法我错了?

  $ git status 
#在分支master上
#你的分支在27次提交后落后于'origin / master',并且可以被快速转发

#已更改但未更新:
#(使用git add< file> ...更新将提交的内容)
#(使用git checkout - < file> ...放弃工作目录中的更改)

#modified:Web Applications / webclient / language / en / lang_copyitems。 ini

没有更改添加到提交中(使用git add和/或git commit -a)

Administrator @ windows-dev〜/ Documents / Workspace / prestige.git
$ git diffWeb Applications / webclient / language / zh / lang_copyitems.ini
diff --git a / Web Applications / webclient / language / zh / lang_copyitems.ini b / Web应用程序/ webclient / language /
索引800c188..ed11c0e 100644
--- a / Web Applications / webclient / language / zh / lang_copyitems.ini
+++ b / Web应用程序/ webclient / language / zh / lang_copyitems.ini
@@ -1 ,12 +1,12 @@
- < EF>< BB>< BF> [Header]
- Description ='copyitems.php'的语言字符串
-
- [Messages]
- 300 =复制
- 301 =关闭
- 302 =复制故事
- 303 =名称
- 304 =在队列中
- 305 =新名称
- 306 =要复制的项目
- 308 =此项目具有未正确设置的必填元数据字段。点击此消息的任何部分
+< EF>< BB>< BF> [标题]
+描述='copyitems.php'的语言字符串
+
+ [消息]
+ 300 =复制
+ 301 =关闭
+ 302 =复制场景
+ 303 =名称
+ 304 =在队列中
+ 305 =新名称
+ 306 =要复制的项目
+ 308 =此项目具有未正确设置的必填元数据字段。点击此消息的任何部分

Administrator @ windows-dev〜/ Documents / Workspace / prestige.git
$ git checkout HEADWeb Applications / webclient / language / zh / lang_copyitems.ini

管理员@ windows-dev〜/ Documents / Workspace / prestige.git
$ git status
#在分支主上
#你的分支位于'origin / master '提交27次,可以快速转发。

#已更改但未更新:
#(使用git add< file> ...来更新将提交的内容)
#(使用git checkout - < file> ...放弃工作目录中的更改)

#modified:Web Applications / webclient / language / zh / lang_copyitems.ini


解决方案

这个设置的问题,如 GitHub指南是在结帐期间完成的自动转换。的存储库......



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



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

注意(在此处显示),如果您需要转换,除了一些文件,你可以在父目录中添加一个.gitattributes文件,内容如下:

  myFile -crlf 

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


I and my collegues are having terrible trouble getting git to behave properly with certain files on our Windows repostiory clones. The clones have been made by cloning a repository which originates on an OSX machine. We have set autocrlf to true, but the problem is that we reguarly find files that git thinks are changed even though we never touch them (we don't even open them in an editor.

The following output illustrates the issue: any ideas where I am going wrong?

$ 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                                
#

解决方案

The problem with this settings, as illustrated by the GitHub guide is an automatic conversion is done during the checkout of the repository...

That means you do not need to open a file to trigger any change.

Is it not possible to keep autocrlf to false, and open those Windows files in editors able to respect the return line characters?

Note (illustrated here), if you need the conversion, except for some files, you could add a .gitattributes in the parent directory, with a:

myFile -crlf

In the file you set attributes to a path (or a pattern), or unset them (with the minus sign).
The crlf attribute is the attribute which tells if a file is affected by the core.autocrlf options. If you unset it, Git won’t mess with the line endings in the file

这篇关于处理Git拒绝重置的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆