git stash pop成功后如何恢复我的git stash

时间:2016-02-03 19:52:17

标签: git git-stash

我对一些文件和一些新文件进行了更改

git pull:说我在几个文件中有冲突

我做了:

git stash
git pull
git stash pop

我预计会发生冲突,但没有冲突。

相反,许多文件现在都是空的。 当前未提交的更改显示从这些文件中删除的所有内容。

我看到的解决方案是:克隆存储库。 “以某种方式恢复”我最后一个弹出的藏匿处并将其保存为补丁并在那里应用。

如何恢复它(它不再存储在存储列表中)

我没有看到最后一个藏匿使用:

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

git fsck --no-reflog | awk '/dangling commit/ {print $3}'

给出:

error: object file .git/objects/02/7745a5151a6237eb1dcd8e4f0df10328809669 is empty
error: object file .git/objects/02/7745a5151a6237eb1dcd8e4f0df10328809669 is empty
fatal: loose object 027745a5151a6237eb1dcd8e4f0df10328809669 (stored in .git/objects/02/7745a5151a6237eb1dcd8e4f0df10328809669) is corrupt

我该怎么办?发生了什么事?

2 个答案:

答案 0 :(得分:0)

我发现官方文件有解决方案。

Recovering stash entries that were cleared/dropped erroneously

  

如果您错误地删除或清除隐藏条目,则不能   通过正常的安全机制恢复。但是,您可以尝试   下面的咒语以获取以下存储项列表:   仍在您的存储库中,但无法再访问:

git fsck --unreachable |
grep commit | cut -d\  -f3 |
xargs git log --merges --no-walk --grep=WIP

答案 1 :(得分:-3)

您是否尝试过使用:

git stash list

你应该有一个你已经完成的藏匿列表。然后,您可以选择要应用的那个:

git stash apply stash@{1}

在你申请藏匿之前我想你想在跑第一个git pull之前让HEAD在同一个位置。