This is basically what my git log looked like.
Obviously, the plan was to revert back to fe4366a, a.k.a. “Commit I want to revert back to”.
My first instinct was to use “git reset –hard fe4366a”. However, the problem with this command is that it only reset my working directory back to that “good” commit. No changes to the branch were made, so I have nothing to push back up to the remote server.
Step 1: Create a new branch (based off of master) for my reversion.
Step 2: Checkout my last good commit to the new branch.
Step 3: At this point, all of the files that were modified in the 3 bad commits have been modified again locally, to match the version in the “Commit I want to revert back to”. Sanity check this just to be sure.
Step 4: After confirming that the reverted changes look OK, commit the changes to the branch.
git commit -m "Reverting changes!"
Done! At this point, my-new-branch can be merged back up to master or you can do whatever you want with it.
There are a few other suggestions on how to revert commits in Git in the answers on that page. The one I have outlined above was the one that worked best for my situation. YMMV. Good luck!