Reputation: 3466
I do have this situation:
Yesterday I merged commit 223a3a6 into the master. The change failed because I didn't adapt some jsons. I quickly reverted the master to not break production servers. Commit 495b186 undid commit 223a3a6.
I fixed the jsons in commit 215b7a6. Now when I want to merge again into the master. I need the changes from commit 223a3a6 and 215b7a6 in the master.
The problem is commit 223a3a6 was already merged into the master. Git doesn't let me merge it into the master again. Our master is write protected, so I can't reset the master.
How can I solve this and merge commit 223a3a6 and 215b7a6 into the master?
Upvotes: 5
Views: 1037
Reputation: 1937
This seems to be pretty much exactly the situation described in the git howto-revert-a-faulty-merge page.
I guess maybe you used "git revert -m" to revert the merge. This reverts the changes to the files, but the fact that you merged that branch is still recorded. As a result, any future attempts to merge that branch will only bring in the revisions after that merge happened.
The documentation for "git merge -m" says:
Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a result, later merges will only bring in tree changes introduced by commits that are not ancestors of the previously reverted merge. This may or may not be what you want.
The solution given in the howto page mentioned above is to revert the commit which reverted the merge (which re-introduces the changes made in that merge), then you should be able to merge the branch to bring in the fixes.
Upvotes: 3