This document is an attempt to be a fairly comprehensive guide to recovering from what you did not mean to do when using git.

via On undoing, fixing, or removing commits in git.