仅从对象中恢复Git存储库 [英] Recovering Git repository from objects only

查看:142
本文介绍了仅从对象中恢复Git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Windows盒子,它已经将它删除了大部分Git仓库(必须已经触发重要工作检测器;)。我留下的(我能找到的)就是物体。我不确定对象的集合是多么完整。是否有可能从物体中恢复物体?据我所知,对象树是完好无损的。所有包装和松散的物品都已到位;我只是没有元数据来说服Git。

解决方案

我会尝试的第一件事是初始化一个新的存储库用 git init 。然后,我将死对象的对象目录复制到新的存储库中。然后我在新的仓库中运行 git fsck



运气好的话你会看到很多如果你运行的是 > git show 和/或 git log 就可以识别一些分支。



要恢复它们,您可以使用 git branch 重新创建命名分支。


I have a Windows box which has taken it into it's head to delete most of a Git repository (must have tripped the Important Work Detector ;). All I have left (that I can find) is the objects. I'm not sure how complete the collection of objects is, either. Is it possible to recover things from just the objects? As far as I can tell, the object tree is intact. All the packs and loose objects are in place; I just don't have the metadata to convince Git.

解决方案

The first thing that I would try is to initialize a new repository with git init. Then I'd copy the objects directory from the dead repository into the new repository. Then I'd run git fsck in the new repository.

With some luck you'll see a whole lot of dangling objects and with a bit more luck some of the dangling objects will be commit objects which will be the tips of lost branches.

If you run git show and/or git log on these commits you may be able to recognize some of the branches.

To "recover" them you can just use git branch to recreate named branches.

这篇关于仅从对象中恢复Git存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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