实际上撤消git stash pop [英] Actually undo git stash pop
问题描述
此问题具有相同的标题,但否同样的问题.这个问题确实是在问丢弃git stash pop的结果".这个问题实际上是
This question had the same title but it is NOT the same question. That question is really asking "Discard results of git stash pop". This question is actually
换句话说
// in branch foo
git stash
git checkout bar
git stash pop # ERROR. I didn't want to pop on top of bar, lots of conflicts
git stash undo-pop # NEED COMMAND TO PUT STASH AND LOCAL FILES BACK AS THEY WERE
git checkout foo
git stash pop
是否有一种方法可以使所有内容恢复到刚键入git stash pop
之前的状态?换句话说,实际上是 UNDO 流行音乐,然后将藏起来的东西放回存储库中,然后将本地文件恢复到我键入git stash pop之前的状态.
Is there a way to get everything back to the state just before I typed git stash pop
? In other words to actually UNDO the pop and put the stashed stuff back into the stash and put the local files back in the state they were before I typed git stash pop.
这也不是如何恢复丢失的存储的欺骗虽然在某些情况下可能会有所帮助
This is also not a dupe of How to recover a dropped stash in Git? Although that might be helpful in certain situations
推荐答案
在您的示例中,要恢复到git stash pop
之前的状态,请使用:
In your example, to restore to the state before git stash pop
, use:
git reset --hard bar
这种形式的git reset
命令将索引和的状态恢复到bar
分支的开头.
This form of the git reset
command restores the state of the index and the working directory to the head of the bar
branch.
因为您在第一个git stash pop
上存在冲突,所以存储区仍然存在在存储区堆栈的顶部.
Because you had conflicts on the first git stash pop
, the stash remains on the top of the stash stack.
从那里,您可以再次git checkout foo
和git stash pop
.
From there, you can git checkout foo
and git stash pop
again.
这篇关于实际上撤消git stash pop的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!