如何在git中从损坏的松散文件中恢复

编程入门 行业动态 更新时间:2024-10-17 07:39:58
本文介绍了如何在git中从损坏的松散文件中恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个损坏的git对象。

第一个fsck:

这个文件的大小在git objects dir中为0。 git fsck --full 致命:松散对象a35c1489005cca1ffeb3c2d3e4d63988408b6a24(保存在.git / objects / a3 / 5c1489005cca1ffeb3c2d3e4d63988408b6a24中)已损坏

然后ls:

ls -l .git / objects / a3 / 5c1489005cca1ffeb3c2d3e4d63988408b6a24 ---------- + 1 sampath ???????? 0 9月13日15:26 .git / objects / a3 / 5c1489005cca1ffeb3c2d3e4d63988408b6a24

该文件不存在

#git cat-file -t a35c1489005cca1ffeb3c2d3e4d63988408b6a24 错误:无法找到a35c1489005cca1ffeb3c2d3e4d63988408b6a24 致命的:git cat-file a35c1489005cca1ffeb3c2d3e4d63988408b6a24:坏文件

当我试图做拉。 我试图删除文件,并做了拉,但没有奏效。它抱怨文件丢失。

当我删除文件并运行fsck时,它显示出很多悬挂对象

#GIT中的fsck --full 断开的链接从提交1e5980c224ff19b19ad99dbefed4c7c64c58aee6 键树a35c1489005cca1ffeb3c2d3e4d63988408b6a24 悬空树0401d636a512b208dffd6ac6e153ab0a061f8d5d 悬空团块58014c0266784a1e3cc1502de82837c5f36c8514 dangling tree 0507fa56260c693cea678eab0343240c5bba06ad 悬挂树130770880c664a0b0cf5a21d037cbdba7480dc90

我累了回几次提交并没有帮助。 有关如何从此恢复的任何指针?

解决方案

看起来树木已损坏。如果你知道你提交的结构,你可以猜测它是什么。希望你可以推断出什么文件被添加或删除。你的斑点和其他树木也会晃来晃去。如果你真的想从这里恢复过来,并且没有其他克隆的回购,这仍然是可能的,但会涉及一些时间和精力以及运气。

希望这有助于。 / p>

I have a git object that is corrupted. The size of the file is 0 in the git objects dir.

First a fsck:

git fsck --full fatal: loose object a35c1489005cca1ffeb3c2d3e4d63988408b6a24 (stored in .git/objects/a3/5c1489005cca1ffeb3c2d3e4d63988408b6a24) is corrupted

Then a ls:

ls -l .git/objects/a3/5c1489005cca1ffeb3c2d3e4d63988408b6a24 ----------+ 1 sampath ???????? 0 Sep 13 15:26 .git/objects/a3/5c1489005cca1ffeb3c2d3e4d63988408b6a24

That file doesn't exist on the disk!?

# git cat-file -t a35c1489005cca1ffeb3c2d3e4d63988408b6a24 error: unable to find a35c1489005cca1ffeb3c2d3e4d63988408b6a24 fatal: git cat-file a35c1489005cca1ffeb3c2d3e4d63988408b6a24: bad file

I saw this error first when I tried to do a pull. I tried removing the file and doing a pull, but that did not work. It complained that the file is missing.

When I removed the file and ran fsck, it showed me a lot of dangling objects

# git fsck --full broken link from commit 1e5980c224ff19b19ad99dbefed4c7c64c58aee6 to tree a35c1489005cca1ffeb3c2d3e4d63988408b6a24 dangling tree 0401d636a512b208dffd6ac6e153ab0a061f8d5d dangling blob 58014c0266784a1e3cc1502de82837c5f36c8514 dangling tree 0507fa56260c693cea678eab0343240c5bba06ad dangling tree 130770880c664a0b0cf5a21d037cbdba7480dc90

I tired going back a few commits and it did not help. Any pointers on how to recover from this?

解决方案

Looks like a tree is corrupted. If you know your structure around those commits, you could guess what it is. Hopefully you can deduce what files were added or removed. Your blobs and other trees will be dangling as well. If you really want to recover from this and have no other clones of the repo, it's still possible but will involve some time and effort and luck.

Hope this helps.

更多推荐

如何在git中从损坏的松散文件中恢复

本文发布于:2023-06-06 01:38:36,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:松散   文件   如何在   git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!