twittergithub logo

Pushed a bunch of changes to the live site this morning (Friday) that weren’t supposed to go until Monday. Woops! Fortunately, I use Git and Git rocks!

First, to undo the changes I typed ‘git revert’ and the SHA of the commit in question. (I think I could have just done ‘git reset --soft HEAD^’ if it weren’t for the fact that I had already done another commit by the time I was informed of my mistake.) Now my working directory is back to the way it was before that commit (but preserving the one that came after).

Then I moved those files onto the live server, undoing my error. Whew! Pretty painless.

Now my working directory or branch is ahead of ‘origin/master’ by 1 commit, and I want to bring back those changes so that I can push them Monday like I’m supposed to. I type ‘git reset --hard origin/master’ and I’m back, like magic.

Thank you, Git developers.