Retrieve a deleted stash that is not a stash-like commit

╄→尐↘猪︶ㄣ 提交于 2021-02-07 20:37:08

问题


I followed the directions here in order to recover a stash I deleted by mistake, but when I try to apply it, I get an error message:

boonie@elementary:~/akanbar-system$ git fsck --unreachable
Checking object directories: 100% (256/256), done.
Checking objects: 100% (702/702), done.
unreachable commit 0f34656bf920ac827702190de57459f77e8310ec
unreachable blob 3af4303a950ade7cca4c8c20b10404bc95b30605
unreachable commit f7142808a8b972f7ec259ca4a3c71c10a9549396
boonie@elementary:~/akanbar-system$ git stash apply 0f34656bf920ac827702190de57459f77e8310ec
'0f34656bf920ac827702190de57459f77e8310ec' is not a stash-like commit

I've tried searching for a solution but I can't find any. Please help!

Solution: Guys, I'm not sure how exactly this worked, but I applied the second unreachable commit instead of the first one (which was the one I wanted) and it restored everything back. They must have been connected somehow. Hopefully this helps someone in the future, and if not, someone who answers with another method below will also help!


回答1:


Recover lost stashed

  1. gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

  2. you can get it by reset or checkout to another branch.

    for Reset: git reset -- hard <hashCode>

    for Checkout: git branch <desire_branch_name> <hashCode>



来源:https://stackoverflow.com/questions/45831689/retrieve-a-deleted-stash-that-is-not-a-stash-like-commit

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!