10

I'm trying to do a merge where I have conflicts and one file has diverged massively. The eclipse git merge tool is great for small changes, but one of my files is large and has hundreds of explicitly marked conflicting sections. I can't for the life of me find an easy way to just do a merge using the "ours" strategy of just using my version and abandoning the remote version.

On Linux or Mac it would be easy for me to just do it from the command line, but I'm on a corporate Windows computer and don't have command-line git. I even tried the workaround of doing "replace with" -> "Head revision" from the file's context menu in the package explorer, but that action is disabled since the repository is in merge conflict mode. This would be an ok solution, but it would still be preferable to have a clear way of applying "ours" or "theirs" strategies to entire files from the merge tool.

I had to resort to a hard reset, making a copy of my file, doing the merge, and then replacing the merged version with my clean copy. Am I missing a much easier way of doing this?

mightybyte
  • 7,282
  • 3
  • 23
  • 39

2 Answers2

10

In the editor of the merge tool, you can edit the left section.

After clicking on Merge Tool, select the "HEAD" option in the dialog that appears, then the left section will contain the same content as HEAD.

So when the left section is already good, just make a small modification, undo it and then save. The modification is necessary because save is not available from the beginning.

robinst
  • 30,027
  • 10
  • 102
  • 108
  • That's not a very feasible solution in this case because the merge inserted tons of <<<< ==== >>>> sections and it would take a lot more time to edit them all than it would to just replace with the head revision of the file. – mightybyte Jul 27 '12 at 13:37
  • 1
    @mightybyte Ah, you have to select the "HEAD" option in the dialog that appears after selecting Merge Tool, then the left section will contain the same content as HEAD. (By the way, this will be one of the next things I'll work on, a "Replace with Ours/Theirs" in the Staging view.) – robinst Jul 29 '12 at 13:32
  • Aha! That makes perfect sense. I haven't tried it yet because I don't have any more large outstanding merges like that, but it sounds like it will solve my problem. I'm not sure why I was unable to figure that out on my own, but a replace with ours/theirs button in the merge view would have probably been something I would have found. – mightybyte Jul 30 '12 at 14:15
  • BTW, if you edit your answer to include what you just said, then I'll accept it. – mightybyte Jul 30 '12 at 14:17
  • 2
    This answer is old, so maybe that is the reason that I don't get any "dialog". Could somebody check if this still is working? – Gustave Feb 01 '18 at 09:36
6

There is now an entry "Replace With" that allows you to select "Ours" or "Theirs" in the context menu for files in the Git Staging view.

jmiserez
  • 2,991
  • 1
  • 23
  • 34