Search code examples
gitmerge-conflict-resolutiongit-merge-conflictbeyondcompare4three-way-merge

Resolving Merge Conflict in IDE Whilst Retaining 3-Way Merge Info


(I am using SourceTree as my Git tool, Beyond Compare to resolve merge conflicts, and Eclipse as my Java IDE.)

The conflict is complex enough that I cannot solve it in the merge tool, and will have to resolve it manually (across multiple files).

Ideally, I'd like to just take my version of the code, look at the conflicts in Beyond Compare, and use that to advise my changes in Eclipse.

Things that don't work:

  1. If I just open up the conflicting version in Eclipse, then the code doesn't compile, so I lose all of the usefulness of static type checking etc.
  2. If I just "resolve using ours/mine" in Git (SourceTree) so that I can open it in Eclipse, then I lose all of the nice three-way merge information that I could have used to resolve the conflict.
  3. Doing a naive diff of the HEAD version of the file with the master version does not solve my problem either - the diff has too little information. I want to have the three-way info.

Am I approaching this the wrong way? Should I be using a different strategy to resolve conflicts? Is there perhaps a feature of Git or BC4 that I could use to keep the conflict info separately whilst editing a specific version of the file?


Solution

  • Something I've found that works (inspired by Stun Brick's suggestion):

    Start the merge, so that the LOCAL, BASE, and REMOTE files are generated.

    Move these files out to a separate directory.

    Resolve the merge by taking the local copy (In SourceTree: Resolve Conflicts -> Resolve Using Mine. In Git: git checkout --ours PATH/FILE).

    Open the local version of the file in Eclipse.

    Open the LOCAL, BASE, and REMOTE files in BC4.

    Now I can edit in Eclipse to my heart's content without affecting what BC4 displays.