I have a master branch, and a develop branch. My production environment uses the master branch, and the develop branch is usually several commits ahead.
I needed to add a quick patch to production. What I would normally do is:
- git checkout master
- git checkout -b my-hot-fix
- (make my hotfix changes, and commit them)
- git checkout develop
- git merge my-hot-fix
- git checkout master
- git merge my-hot-fix
In this case, I accidentally forget step 1, which means that I was on the develop branch when I created my-hot-fix. I didn't realise this until I got to the last step, and merged the hot fix into master. Instead of getting one small change, I received a number of prior commits from the develop branch.
How do I reverse this? Note that I have not pushed the changes upstream yet.
Note: there are other SO questions about accidental merging. My problem is more than that - it came about because the branch I am merging was created from the wrong branch.