git: shorter way to deal with commits you don't want to push?

view story

http://www.linuxquestions.org – Let's say... I pull from my remote branch origin/master into local master. I edit something, commit, and then suddenly realize that commit was the stupidest idea ever conceived, or perhaps a horrible mistake. I could "git revert" back to the previous commit, but then I'm two commits ahead of origin/master, and it would be pretty embarrassing to push two utterly pointless commits. My solution is to 1. checkout the previous commit into a detached head 2. delete master 3. recreate branch master from the detached head 4. set the new branch master to track origin/master Is this the sh (HowTos)