致命错误后重新创建Git Ref [英] Recreate Git Ref after Fatal Error

查看:274
本文介绍了致命错误后重新创建Git Ref的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近不得不执行一次硬重启,并且当我尝试访问特定分支时(在访问其他分支时不会发生这种情况),我现在在git中收到错误消息:

  $ git checkout branchName 
致命:无法读取对象ebca165c3ec7ecd7124f41983dd264e4e1dc0125:无效参数

问题与此处所述的相似:如何恢复损坏的git存储库?,但不同之处在于我目前不在该分支上执行 git status 。此外,如果我调用 git reflog ,我收到相同的错误消息。



我试图删除有问题的分支使用 git branch -d branchName git分支-D branchName ,但没有成功。



显然,我希望保留所有的分支和数据,但如果解决方案是删除特定的分支,那很好。此外,不知道这是否有帮助,甚至是重要的,但在这个分支上执行的最后一个操作是 rebase



可能的解决方案是重建每个存在的单个分支的当前ref,排除无效分支吗?

作为一个方面说明,我没有一个远程源代码,我很喜欢 clone ,因此需要任何本地解决方案。此外,我使用PHP的情况下,任何原因。



谢谢。






编辑:



运行 git fsck --full 我收到以下消息:

  $ git fsck --full 
致命:无法读取对象687f624bd239de165307d18a8904a77adb32c8a1:无效参数

...这很奇怪,因为它似乎是指不同的散列。

我终于找到了如何回答这个问题......



只需进入文件夹 .git 并删除 refs / heads / BadBranch



其余的分支 es可以像平常一样工作,同时只会损坏损坏的分支中的信息。


I recently had to perform a hard reboot and I am now receiving an error in git when I try to access a specific branch (this does not happen when accessing other branches):

$git checkout branchName
fatal: failed to read object ebca165c3ec7ecd7124f41983dd264e4e1dc0125: Invalid argument

The problem is similar to the one described here: How to restore a corrupted git repository?, but differs in the fact that I am not currently on that branch to perform git status. Also, if I call git reflog I receive the same error message.

I tried to delete the branch in question using git branch -d branchName and git branch -D branchName, but have had no success.

Obviously, I would love to keep all of the branches and data, but if the solution is to delete that specific branch, then that is fine. Also, don't know if this helps or even matters, but the last action performed on this branch was rebase.

Would a possible solution be to reconstruct the current ref from each of the individual branches that exist, excluding the invalid branch?

As a side note, I don't have a remote source that I'm comfortable cloneing from at this point, so any local solutions are desired. Also, I'm using PHP in case that matters for any reason.

Thanks.


Edit:

Running git fsck --full I receive the following message:

$git fsck --full
fatal: failed to read object 687f624bd239de165307d18a8904a77adb32c8a1: Invalid argument

...which is odd because it seems to refer to a different hash.

解决方案

I finally found out how to answer this question...

Simply go into the folder .git and delete refs/heads/BadBranch

This allows the rest of the branches to work as they normally should, while only losing information from the corrupted branch.

这篇关于致命错误后重新创建Git Ref的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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