After resolving a merge conflict and committing, it has become apparent that my manual merge conflict resolution was wrong. I have already staged, committed, and pushed the repo. How can I get the conflicting file back into the conflicting state, such that I might resolve it differently?
Note that it is too late for git checkout -m
as I've already committed the incorrect merge resolution.
Starting from a clean working directory, I would hard reset back to before the merge, start a new branch, and perform the merge again. You could then perform a diff between the original merge result branch and your new branch to get a patch file to apply on the original branch. Since you have already pushed your result, you will want to create a new commit correcting the merge commit rather then performing a force push after editing the history.
Overly detailed version:
If your current history looks something like this and
c
is the merge commit you want to change.Starting from a completely clean working directory.
This will create something like this...
That's probably really confusing but hopefully you get the idea. Now you can perform a diff between the
old_merge
branch and thenew_merge
branch to get the changes you will need to make on master.You could use the
patch
UNIX utility to apply the difference between the two branches after you have checked out master again.Hopefully this helps. Let me know if you are confused by anything.