Originally published on the old depletionmode / 2of1 blog (archived copy).
The easiest way to undo a rebase is to find the relevant commit as it was immediately before the rebase using git reflog.
You can then reset to that commit; e.g.:
git reset --hard HEAD@{50}