My coworker got himself into some trouble yesterday. He moved master
about 100 commits behind origin/master
(I'm not sure how he did that, probably with this), then he committed. The result was that master
now was at his new commit and the previous commit was 100 commits behind origin/master
. It looked like this:
master *
|
| * origin/master
| *
... ~one hundred commits below
| *
\ *
\
*
I didn't feel confident in how to fix this so the way we did it is by throwing away the repo and cloning it again. What's the right way to fix this mistake?
His intent was to create a new branch named hotfix
100 commits before origin/master
and commit these changes to it. I don't think he really wanted to move master
at all.
I'll take a stab at fixing this:
git checkout master
git branch hotfix
#still on master
git reset --hard HEAD~1
git branch -f master <commit of origin/master>