本文介绍了修复损坏的git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
由于电源问题,我的git存储库在几次硬重启后损坏了,现在我无法修复它(我在最后一次电源故障时正在暂存一些文件)
$ git status 致命:无法读取对象3d18855708b0f127d40c13c679559d7679228b69:无效参数 $ git fsck 致命:未能读取对象24377c609184c192f3f3c1733bac7115c1080758:无效参数 $ git分支-a (...作品,列表分支...) $ git checkout someotherbranch 致命:无法读取对象3d18855708b0f127d40c13c679559d7679228b69 :无效的参数 $ git log 致命:无法读取对象3d18855708b0f127d40c13c679559d7679228b69:无效参数 $ git log someotherbranch (... works,shows commitits ...)所以,正如你所看到的,我目前的分支非常糟糕,我似乎无法修复它。任何ideea我可以尝试修复这个问题?
解决方案对于类似情况,我的解决方案是替换 .git / (可以在 .git / logs / HEAD 中找到)。 / p>
My git repository got corrupted after a couple of hard reboots due to power supply issues and now I'm unable to fix it (I was in the middle of staging some files at the last power failure)
$ git status fatal: failed to read object 3d18855708b0f127d40c13c679559d7679228b69: Invalid argument $ git fsck fatal: failed to read object 24377c609184c192f3f3c1733bac7115c1080758: Invalid argument $ git branch -a (...works, lists branches...) $ git checkout someotherbranch fatal: failed to read object 3d18855708b0f127d40c13c679559d7679228b69: Invalid argument $ git log fatal: failed to read object 3d18855708b0f127d40c13c679559d7679228b69: Invalid argument $ git log someotherbranch (...works, shows commits...)So, as you can see, my current branch is pretty screwed up and I don't seem to be able to fix it. Any ideea what can I try to repair this?
解决方案My solution for a similar situation was to replace a hash of the damaged object in .git/refs/heads/my-working-branch with a hash of previous commit (which can be found in .git/logs/HEAD).
更多推荐
修复损坏的git存储库
发布评论