如何修复一个坏的混帐树对象 [英] How to fix a bad git tree object

查看:826
本文介绍了如何修复一个坏的混帐树对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个版本库的本地副本,不再有任何远程关联的副本。
我试图把这个回购推进到一个新的遥控器,但是每当我收到这条消息时:

  error:可能没有阅读9eefe9305253b2c039a54cbc8aa22f7f8e6e8790 
致命:坏树对象9eefe9305253b2c039a54cbc8aa22f7f8e6e8790

我在这里读到类似的问题,修复它的方法是从存储库的其他副本中检索此对象或进行硬重置。我无法做任何两者,因为我没有这个回购的副本。



有没有办法简单地删除这个提交或其他类型的解决方案这将允许我推动回购到新的远程保持历史吗?解决方案

为了实际解决问题并且不丢失任何数据(假设那棵树是唯一缺少的对象,我怀疑)你可以试试这个:
$ b


  1. 签出提交的父提交相关的树

  2. 尝试 git cat-file -p 和有问题的提交的名称,以查看提交消息的内容(希望它会告诉您更改了什么)

  3. 现在您可能能够确定所做的更改,并且可以从中推断目录结构。
  4. 如果3个工作正常,
  5. 那么您可以使用文本编辑器和zlib压缩器手动创建您的树。 tee文件中的条目将是其他树对象或Blob。希望在两次提交之间共享大多数文件和文件夹(没有更改)。这将允许您重用检出提交的树对象中的大部分条目。


I have a local copy of a repository that not longer have any remote associated to it. I'm trying to push this repo into a new remote however everytime I get this message:

error: Could not read 9eefe9305253b2c039a54cbc8aa22f7f8e6e8790
fatal: bad tree object 9eefe9305253b2c039a54cbc8aa22f7f8e6e8790

I read in similar questions here that one way to fix it is retrieving this object from other copies of the repository or doing a hard reset. I can't do any of both since I don't have another copy of this repo.

Is there a way to simply remove this commit or some other kind of solution that will allow me to push the repo to the new remote keeping history?

解决方案

To actually fix the problem and not loose any data (provided that that tree is the only missing object, which I doubt) you could try this:

  1. checkout the parent commit of the commit with the concerning tree
  2. try git cat-file -p with the name of the problematic commit to see what the commit message says (hopefully it will tell you what changed)
  3. now you might be able to determine the changes that were made and from this the directory structure can hopefully be inferred.
  4. if 3 worked, then you can create your tree manually using a text editor and a zlib compressor. The entries in the tee file will be other tree objects or blobs. Hopefully most of the files and folders are shared (have no changes) between the two commits. This will allow you to reuse most of the entries from the tree object of the checked out commit.

这篇关于如何修复一个坏的混帐树对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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