加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

windows – 处理Git拒绝重置的文件?

发布时间:2020-12-14 01:36:21 所属栏目:Windows 来源:网络整理
导读:我和我的同事们在使用我们的 Windows repostiory克隆上的某些文件时让git正常运行会遇到严重的麻烦.克隆是通过克隆源自OSX机器的存储库而制作的.我们已经将autocrlf设置为true,但问题是我们定期查找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                                
#

解决方法

如 GitHub guide所示,此设置的问题是在结帐存储库期间自动转换…

这意味着您无需打开文件即可触发任何更改.

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

注意(illustrated here),如果您需要转换,除了某些文件,您可以在父目录中添加.gitattributes,其中包含:

myFile -crlf

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读