I have run into a bit of a problem here: I had a problem-specific branch 28s
in Git, that I merged in the general develop
branch. Turns out I had d
You have to "revert the revert". Depending on you how did the original revert, it may not be as easy as it sounds. Look at the official document on this topic.
---o---o---o---M---x---x---W---x---Y
/
---A---B-------------------C---D
to allow:
---o---o---o---M---x---x-------x-------*
/ /
---A---B-------------------C---D
But does it all work? Sure it does. You can revert a merge, and from a purely technical angle, git did it very naturally and had no real troubles.
It just considered it a change from "state before merge" to "state after merge", and that was it.
Nothing complicated, nothing odd, nothing really dangerous. Git will do it without even thinking about it.So from a technical angle, there's nothing wrong with reverting a merge, but from a workflow angle it's something that you generally should try to avoid.
If at all possible, for example, if you find a problem that got merged into the main tree, rather than revert the merge, try really hard to:
- bisect the problem down into the branch you merged, and just fix it,
- or try to revert the individual commit that caused it.
Yes, it's more complex, and no, it's not always going to work (sometimes the answer is: "oops, I really shouldn't have merged it, because it wasn't ready yet, and I really need to undo all of the merge"). So then you really should revert the merge, but when you want to re-do the merge, you now need to do it by reverting the revert.
I just found this post when facing the same problem. I find above wayyy to scary to do reset hards etc. I'll end up deleting something I don't want to, and won't be able to get it back.
Instead I checked out the commit I wanted the branch to go back to e.g. git checkout 123466t7632723
. Then converted to a branch git checkout my-new-branch
. I then deleted the branch I didn't want any more. Of course this will only work if you are able to throw away the branch you messed up.