How to undo git stash clear

git

Solution

As it may be found in the documentation of git stash, you may be lucky if this works:

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

If you find the stash you cleared by mistake, then you can do:

git stash apply <stash>

EDIT: Use this command instead `git fsck --unreachable | grep commit | cut -d ' ' -f3 | xargs git log --merges --no-walk --grep=WIP`

Problem

I executed `git stash save "ABC"`. Then by mistake I did `git stash clear` . How can I retrieve the data that was in stash ABC?

Original source