Reputation: 454
I have three branches: master, A and B.
Branch "A" and "B" should be independent to each other. After the pull requests, master got updated from A and B. Now, I have accidentally merged B into A.
Immediately, I have reverted this merge via git revert -m
But now when I pull B into master, revert merge in A destroys changes from branch B. This is happening because of branch A have "revert merge B" commit.
How I can remove "revert merge branch B" and "merge branch B" commits? I tried to use git -rebase command, but it doesn't help me, git creates anthoer branch that is not in pull request.
Upvotes: 7
Views: 5149
Reputation:
Simple answer: git docs
Revert the revert because
So if you think of "revert" as "undo", then you're going to always miss this part of reverts. Yes, it undoes the data, but no, it doesn't undo history.
Adding more to it:
Unfortunately, you hit the most popular problem in the history of git users :)
Your problem is a faulty merge git merge branch B/branch A
, which you tried to recover it by git revert
Remember, So a "revert" undoes the data changes, but it's very much not an "undo" in the sense that it doesn't undo the effects of a commit on the repository history.
I think the better person to answer this question would be linus torvalds, I can't find the better person than him.
Reverting a regular commit just effectively undoes what that commit
did, and is fairly straightforward. But reverting a merge commit also
undoes the _data_ that the commit changed, but it does absolutely
nothing to the effects on _history_ that the merge had.
So the merge will still exist, and it will still be seen as joining
the two branches together, and future merges will see that merge as
the last shared state - and the revert that reverted the merge brought
in will not affect that at all.
So a "revert" undoes the data changes, but it's very much _not_ an
"undo" in the sense that it doesn't undo the effects of a commit on
the repository history.
So if you think of "revert" as "undo", then you're going to always
miss this part of reverts. Yes, it undoes the data, but no, it doesn't
undo history.
Some of the links solving git revert problem:
Upvotes: 13