Git necromancy: recover lost code from repo history

Trashed a function but need it again? Find it in your git history with:

$ git log -Ssearchterm

Note: No space between the -S flag and your search term.

If you want to then restore the source file in its entirety:

$ git show HEAD^ > ~/

Turns out in this case I was able to find the supposedly-missing function in another file.

Sometimes you just gotta $ find . -name "*.py" | xargs grep <term>.