仅从对象恢复 Git 存储库
我有一个 Windows 盒子,它已经把它带入了它的头部,以删除大部分 Git 存储库(一定已经触发了重要工作检测器;)。我所剩下的(我能找到的)就是物体。我也不确定对象的集合有多完整。是否可以仅从对象中恢复内容?据我所知,对象树是完整的。所有包裹和松散物品均已就位;我只是没有元数据来说服 Git。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我要尝试的第一件事是使用 git init 初始化一个新的存储库。然后,我将对象目录从失效存储库复制到新存储库中。然后我会在新存储库中运行 git fsck 。
如果运气好的话,您会看到很多悬空对象,如果运气好一点,一些悬空对象将是提交对象,它们将是丢失分支的提示。
如果您在这些提交上运行 git show 和/或 git log,您可能能够识别一些分支。
要“恢复”它们,您只需使用 gitbranch 重新创建命名分支即可。
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 rungit 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/orgit 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 checkout master ,我会从它开始。
If you haven't already tried
git checkout master
, I'd start with that.尝试使用这篇文章
如何恢复硬盘损坏的 Git 对象磁盘故障?
该答案可能有一些 *nix 相关信息。如果有帮助请告诉我。
我会看看它有什么作用。
try using this post
How to recover Git objects damaged by hard disk failure?
that answer may have some *nix related info. Let me know if it helps.
Ill see what it does.