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 done it too fast, so I used git-revert to undo the merge. Now, however, the time has come to merge 28s
into develop
, but git-merge command sees the original merge, and happily announces that all is well and branches have been already merged. What do I do now? Create a 'Revert "Revert "28s -> develop"" ' commit? Doesn't seem to be a good way to do it, but I can't imagine any other at the moment.
What the tree structure looks like:
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 branchgit 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.To revert the revert without screwing up your workflow too much:
Your feature branch should now be able to be merged as normal when you're ready for it. The only downside here is that you'll a have a few extra merge/revert commits in your history.
You have to "revert the revert". Depends on how did you revert that, it may not be as easy as it sounds. Look at the official document on this topic.
to allow:
To revert a revert:
Instead of using
git-revert
you could have used this command in thedevel
branch to throw away (undo) the wrong merge commit (instead of just reverting it).This will also adjust the contents of the working directory accordingly. Be careful:
git-reset
. All commits after the one you specify as thegit reset
argument will be gone!I recommend to study the
git-reset
man-page carefully before trying this.Now, after the reset you can re-apply your changes in
devel
and then doThis will be a real merge from
28s
intodevel
like the initial one (which is now erased from git's history).Let's assume you have such history
Where A, B failed commits and W - is revert of M
So before I start fixing found problems I do cherry-pick of W commit to my branch
Then I revert W commit on my branch
After I can continue fixing.
The final history could look like:
When I send a PR it will clearly shows that PR is undo revert and adds some new commits.