克隆后显示随机文件为已修改;不能抛弃它们 [英] Git Shows Random Files as Modified After Clone; Can't Discard Them

查看:64
本文介绍了克隆后显示随机文件为已修改;不能抛弃它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只要我在我的MacBook Pro上克隆某个特定的回购,我立即会看到在该回购中修改过的文件。我试过git pull,git checkout,git reset,似乎没有任何东西可以让这些所谓的修改过的文件消失。我一直在使用git,之前从未见过。什么可能导致它?

解决方案

有一个配置文件,标记某些类型的源文件为文本,换行符将被转换。在存储库的根目录中有一个 .gitattributes 文件,或者在主目录中有一个全局的〜/ .gitattributes

您可以做两件事:


  • 修改 .gitattributes 配置,以便文件不会被标记为 text > 提交建议的更改使存储库符合规范;我推荐这个解决方案



我会说这样做的目的是让git处理换行符,所以有人在 .gitattributes 之后一些文件是使用Windows CRLF endlines提交的,如果发生这种情况,git不会自动修复已存在的文件在工作树中检出。但是一个新的克隆会将这些文件重新加入到工作树中,并自动修复它们,所以下次您将工作树与索引进行比较时,git会发出抱怨。


As soon as I clone a certain repo on my macbook pro, I immediately see files as modified in that repo. I've tried git pull, git checkout, git reset, nothing seems to make these supposedly modified files go away. I've been using git for a while and have never seen this before. What could possibly be causing it?

解决方案

There is a configuration file that marks certain types of source files as text, for which newlines will be converted. There's either a .gitattributes file in the root of the repository, or a global ~/.gitattributes in your home directory.

You can do two things:

  • modify the .gitattributes configuration so that files aren't marked as text anymore
  • commit the proposed changes so that the repository becomes consistent with the specification; I'd recommend this solution

I'd say that the intention was to properly let git handle newlines, so someone added the configuration in .gitattributes after some files were committed with the Windows CRLF endlines, and when that happens, git doesn't automatically fix the existing files that were already checked out in the working tree. But a new clone will get those files into the working tree anew and automatically fix them, so git will complain next time you compare the working tree with the index.

这篇关于克隆后显示随机文件为已修改;不能抛弃它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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