The steps are quite simple. Assuming I’m in the master branch with a few commits I’d like to rewind but keep the code that I have in a new branch.
1. Create a new branch for the current code
git branch new-experiments
2. Determine how far back I’d like to rewind master
When looking at the log, find the last commit I want to keep and make a note of its hash tag. It will be used in the next step.
3. Rewind/move master back to found commit
git reset --hard ab15cd26
4. Go back to where I was by checking out the newly created branch
git checkout new-experiments
5. Also, I got an error message when I tried to push these changes to a central repository (Github) for the master branch. So I needed to force the push with:
git push --force github master