运行“git Push”时出现损坏错误

发布于 2024-11-15 10:33:51 字数 691 浏览 4 评论 0原文

我尝试运行 git push 并收到损坏错误:

% git push
Counting objects: 62, done.
Delta compression using up to 2 threads.
error: corrupt loose object 'f2310668fe335b36c513e50fcd99744e8fd5c2e0'
fatal: object f2310668fe335b36c513e50fcd99744e8fd5c2e0 is corrupted
error: pack-objects died with strange error

该错误挂在最后一行,直到我按 Ctrl+C。

我读到运行 git gc 可能会有所帮助,所以我这样做并得到了类似的错误:

% git gc
Counting objects: 493, done.
Delta compression using up to 2 threads.
error: corrupt loose object 'f2310668fe335b36c513e50fcd99744e8fd5c2e0'
fatal: object f2310668fe335b36c513e50fcd99744e8fd5c2e0 is corrupted
error: failed to run repack

我应该做什么来解决这个问题?

I tried to run git push and got a corruption error:

% git push
Counting objects: 62, done.
Delta compression using up to 2 threads.
error: corrupt loose object 'f2310668fe335b36c513e50fcd99744e8fd5c2e0'
fatal: object f2310668fe335b36c513e50fcd99744e8fd5c2e0 is corrupted
error: pack-objects died with strange error

This hangs on the last line until I hit Ctrl+C.

I read that running git gc might help, so I did that and got a similar error:

% git gc
Counting objects: 493, done.
Delta compression using up to 2 threads.
error: corrupt loose object 'f2310668fe335b36c513e50fcd99744e8fd5c2e0'
fatal: object f2310668fe335b36c513e50fcd99744e8fd5c2e0 is corrupted
error: failed to run repack

What should I do to fix this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

时光匆匆的小流年 2024-11-22 10:33:51

克隆存储库的备份。如果损坏的对象 ID 是 $OBJECTID,请执行以下操作:

在新存储库中:

git cat-file -t $OBJECTID > object-type
git cat-file $(cat object-type) $OBJECTID > object-contents

将这两个新文件移动到旧存储库

在损坏的存储库中,移走损坏的对象:

mv .git/objects/XX/XXXXXXXXXXXXXXXXXX .
git hash-object -t $(cat object-type) -w object-contents

这应该将对象写入 git 的数据库,并将 $OBJECTID 输出到 STDOUT 。如果它输出一些其他 SHA1 id,则说明您犯了一个错误,您应该删除该错误的对象。

Clone a backup of your repository. If the corrupted object id is $OBJECTID, do this:

In new repository:

git cat-file -t $OBJECTID > object-type
git cat-file $(cat object-type) $OBJECTID > object-contents

Move those two new files to the old repository

In corrupt repository, move away your corrupt object:

mv .git/objects/XX/XXXXXXXXXXXXXXXXXX .
git hash-object -t $(cat object-type) -w object-contents

This should write the object into git's database, and output $OBJECTID to STDOUT. If it outputs some other SHA1 id, you have made a mistake and you should delete that wrong object.

彼岸花ソ最美的依靠 2024-11-22 10:33:51

看起来它是您自己最近尝试推送的对象之一,其中包含损坏的对象。 。

git fetch

然后,在远程跟踪分支之上重新调整您的更改 这应该不会执行任何操作

git rebase origin/yourbranch

如果您处于快进情况,那么如果不是 ff 情况,

,您应该在提交上收到错误,该错误要么本身已损坏,要么在它指向的树和 blob 结构中指向的内容。如果这是一种 ff 情况,请

git rebase -i origin/yourbranch

不要进行任何更改。保存并退出,git 将在其所在位置重写提交。这应该不会导致任何提交失败,从而帮助您追踪坏对象。

希望这有帮助

looks like it is one of your own recent objects that you are trying to push that contains a corrupt object. Do

git fetch

then rebase your changes on top of the remote tracking branch. If you're in a fast forward situation, this should do nothing

git rebase origin/yourbranch

if it's not a ff situation, you should be getting an error on the commit that is either itself corrupt or something it points to in the tree and blob structure it points to.

If this was a ff situation, do a

git rebase -i origin/yourbranch

don't change anything. Save and quit and git will rewrite the commits on top of where they are. This should fail no a commit that will help you track down the bad object.

hope this helps

梦途 2024-11-22 10:33:51

您可以尝试从外部源重新克隆您的存储库,然后从您自己更改的存储库中获取更改。如果缺陷对象不是由您自己的提交之一创建的,则此方法有效。

git clone http://foo/bar
cd bar
git fetch ../orig [branch1:branch1 [branch2:branch2[...]]]

您还可以尝试从新克隆中提取对象 f2310668fe335b36c513e50fcd99744e8fd5c2e0 并将其放入 .git/objects/f2/310668fe335b36c513e50fcd99744e8fd5c2e0 中,然后再次运行 git gc,但请使用您的存储库副本执行此操作。

You can try to re-clone your repo from an external source, and then fetch the changes form your own changed one. This works if the defect object is not created by one of your own commits.

git clone http://foo/bar
cd bar
git fetch ../orig [branch1:branch1 [branch2:branch2[...]]]

You can also try to extract object f2310668fe335b36c513e50fcd99744e8fd5c2e0 from the fresh clone and place it into .git/objects/f2/310668fe335b36c513e50fcd99744e8fd5c2e0 and run git gc again, but do this with a copy of your repo.

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