Actually undo git stash pop

前端 未结 4 2112
迷失自我
迷失自我 2021-02-13 15:16

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

4条回答
  •  花落未央
    2021-02-13 15:35

    So, I'm not 100% sure of the answer in all cases. In my case when I typed git stash pop and I was on branch bar there were conflicts. So while it applied the stash it didn't drop the stash. So to undo and correctly apply the stash to branch foo it was just

    git reset --hard      # resets bar to before the stash pop
    git checkout -b foo
    git stash pop         
    

    If there had been no conflicts with branch bar then it's just

    git stash             # restash
    git checkout -b foo
    git stash pop
    

提交回复
热议问题