修复损坏的git存储库

编程入门 行业动态 更新时间:2024-10-28 20:31:04
本文介绍了修复损坏的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存储库

本文发布于:2023-10-16 20:19:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1498628.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:git

发布评论

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

>www.elefans.com

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