Undo a fast-forward merge
Solution 1:
If you reset the branch master, it won't touch develop branch. In order to reput all in order, you should do:
git checkout master
git reset --hard sha-of-B
git checkout develop
git reset --hard sha-of-D
git checkout master
git merge develop --no-ff
Solution 2:
- imagine you are still on master where you merged and pushed
-
git reset --hard @{1}
- this resets branch “master” to where it was one step back on your computer (i.e. at “B”)
- for develop do nothing, because it should still be at “D”
-
git push publish develop
- this pushes branch “develop” in the usual way
-
git push publish master --force-with-lease
- pushes branch “master” backwards, with the permission gained via
--force-with-lease
in a safe way - the use of
--force
might silently overwrite work from others, so I never use that
- pushes branch “master” backwards, with the permission gained via
- or both push operations together with this surprising syntax:
git push publish develop --force-with-lease=master