Let's start with a general advice: Never commit and/or push if you're half asleep!
If you don't follow this, like I did, you might find this useful:
If you have commited but not pushed your repository to a remote server yet, you can remove this last commit with
git reset --soft HEAD^1
The
--soft tells git to delete only the commit itself, but not your changes. There is also the
--hard switch, which will delete also your changes. Use this with care!
If you have already pushed your commit, than the way to go is:
git revert HEAD
This will generate a new commit, but without the changes from your sleepy-headed commit.