仅从对象恢复 Git 存储库

发布于 2024-11-03 05:08:46 字数 157 浏览 3 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

最后的乘客 2024-11-10 05:08:48

我要尝试的第一件事是使用 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 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.

っ〆星空下的拥抱 2024-11-10 05:08:48

如果您还没有尝试过 git checkout master ,我会从它开始。

If you haven't already tried git checkout master, I'd start with that.

桃酥萝莉 2024-11-10 05:08:48

尝试使用这篇文章

如何恢复硬盘损坏的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文