How to recover a dropped stash in Git?

前端 未结 19 1702
别跟我提以往
别跟我提以往 2020-11-22 01:42

I frequently use git stash and git stash pop to save and restore changes in my working tree. Yesterday I had some changes in my working tree that I

相关标签:
19条回答
  • 2020-11-22 02:18

    In OSX with git v2.6.4, I just run git stash drop accidentally, then I found it by going trough below steps

    If you know name of the stash then use:

    $ git fsck --unreachable | grep commit | cut -c 20- | xargs git show | grep -B 6 -A 2 <name of the stash>

    otherwise you will find ID from the result by manually with:

    $ git fsck --unreachable | grep commit | cut -c 20- | xargs git show

    Then when you find the commit-id just hit the git stash apply {commit-id}

    Hope this helps someone quickly

    0 讨论(0)
提交回复
热议问题