I have a dev
branch which already merged with branches featureA
and featureB
.
I merged that dev
branch to master
and pushed to remote. Later I identified featureB
is not yet ready to merge with master
as there is a faulty commit. So I revert that merge of dev
--> master
.
git revert -m 1 <merge-commit-hash>
Then I am trying to merge featureA
to master
. But I cannot merge. It will say Already up to date
.
I know the reason as Linus Torvalds said,
Linus explains the situation:
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.
In this situation only solution to merge that dev
again to master
is revert the revert commit
. But I only want to merge the one branch included in dev
branch, that is featureA
How can I merge the branch (featureA
) to mainline branch (master
), that included in reverted merge branch (dev
) ?