Undoing accidental git stash pop

前端 未结 3 737
隐瞒了意图╮
隐瞒了意图╮ 2021-01-29 23:34

I stashed some local changes before doing a complicated merge, did the merge, then stupidly forgot to commit before running git stash pop. The pop created some pro

3条回答
  •  终归单人心
    2021-01-29 23:54

    From git stash --help

    Recovering stashes that were cleared/dropped erroneously
       If you mistakenly drop or clear stashes, they cannot be recovered through the normal safety mechanisms. However, you can try the
       following incantation to get a list of stashes that are still in your repository, but not reachable any more:
    
           git fsck --unreachable |
           grep commit | cut -d\  -f3 |
           xargs git log --merges --no-walk --grep=WIP
    

    This helped me better than the accepted answer with the same scenario.

提交回复
热议问题