Recover a dropped stash in Git

There’s a great thread over on Stack Overflow about how to recover a dropped stash in Git. Here’s a handy little bash script for doing exactly that:

#!/bin/bash
HASHES=`git fsck --no-reflog | awk '/dangling commit/ {print $3}'`
for HASH in $HASHES; do
	clear
	echo $HASH
	echo
	git show $HASH
done

After you have the SHA hash of the stash in question, you can apply it easily with:

git stash apply <SHA>

Jon Stewart

Quote

I have to say, as someone who is not Christian, it’s hard for me to believe Christians are a persecuted people in America. God-willing, maybe one of you one day will even rise up and get to be president of this country – or maybe forty-four in a row. But, that’s my point, is they’ve taken this idea of no establishment as persecution, because they feel entitled, not to equal status, but to greater status.

–Jon Stewart