Git is a phenomenal tool, but I have yet to wrap my mind around the best way to undo pushed changes. Here’s the situation.
I’m on a branch, and have pushed several commits to GitHub. It has since been decided that I’ve gone too far down the rabbit hole, and we need to scrap several of the commits I’ve done, and start over. Essentially, I need to reverse all of the pushed commits, back to a previous one. Here are the two commands that I think are appropriate
git revert # - creates a new commit that "undoes" the changes of one specific commit
git checkout 'commit SHA' # - sets the head to that specific commit, wherein I will re-push to the repo, undoing my changes... I think
So, am I right? Do I need to do a git checkout on the specific commit I want to return to? Or is there something in this convoluted process that I am not understanding?
Thanks.
Try
git reset: http://git-scm.com/docs/git-reset