I have this poor habit you know… Whenever I accumulate a lot of stashes in some repository I just get a little maniac and start cleaning everything. I found it sometimes even funny to open the terminal and play around with some bash to delete the stashes, look:

please send help

# if you're just flashing by don't copy and past this line into your terminal
for i in {1..10}; do git stash drop; done

Well, it happens that today (a few hours ago actually) I just did this and regretted the moment I did because there was this huge feature that for some reason I had locally stashed and not committed
¯\_(ツ)_/¯.

Good news!, the commits are not actually gone until git runs garbage collection, so to check the list of commits that might still be rescued just go ahead and type:

git fsck --unreachable

or maybe

git fsck --unreachable | grep commit

because you actually need to check whether your hash is somewhere referenced as a unreachable commit.

Then all you need to do once you find your stash (if you don’t know the hash I’m afraid you will have to apply stashes until you find it) is just:

git stash apply <hash>

Here, some cool references on git stash:


And that’s it, hope this saves you just like it saved me.


Have a nice day.