Last Updated: February 25, 2016
·
2.915K
· clawfire

Recover a dropped stash

Ok sometime you're a little bit tired and instead of making a git stash pop [ref] you make a git stash drop [ref].

Keep calm, and keep reading

So how to recover a dropped stash ?

  • First of all we launch gitk to get a repo browser and tell them to show every single commit in the repository. ever. regardless of whether it is reachable or not :

    gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

  • Right now just browse your code and find the SHA1

  • Quit gitk and use git stash apply [SHA1] and breathe

Credits