Re-use conflict resolution with Git

git, git-rerere, merge, merge-conflict-resolution

Solution

The simplest way to implement what you're asking for is probably to retroactively turn rerere on:

git config rerere.enabled true    # with rerere turned on,

git checkout $o^1             # rerun the original merge
git merge $o^2
git read-tree --reset -u $o:  # resolve conflicts exactly as before

git commit                    # throwaway commit to feed the results to rerere

and now that rerere has seen what you did with those conflicts,

git checkout -B old-master $o^1   # rewind `old-master` to before the merge
git merge master              # rerun it with current ancestry

Problem

Can I tell Git to re-use the conflict resolution from an existing merge commit? I had rerere disabled at the time of commit. The new merge commit contains a few additional commits on the "ours" side of the merge (but they should not introduce new conflicts as they modified a different set of files). For instance, take the following DAG: ``` m [master] Add new stuff * | o [old-master] Merge branch A (conflicts) |/a [branch A] n * * * */ * ``` Now, what I want to do is to bring commits `m` and `m^` into the branch `old-master` (and later make that the new master). I don't want to simply merge `master` into `old-master`, since it will create a new merge commit (albeit without conflicts). I want to recreate commit `o` with `m` and `a` as parents. The new DAG should look like: ``` p [old-master] Merge branch A (same conflict resolution as old commit o) /| m | [master] Add new stuff * | | a [branch A] n * * * */ * ``` I don't mind using rerere, if I can tell it afterwards to record the resolution of the existing merge commit (`o`).

Original source

Related problems