54

The documentation is here: http://www.kernel.org/pub/software/scm/git/docs/git-mergetool.html A handy guide is here: http://ryanflorence.com/git-for-beginners/

However, neither of them explain how to use mergetool's filemerge.

The guide I read says "I hit enter and FileMerge pops up and I deal with the conflicts:" but it doesn't mention how to "deal with the conflicts".

When I run:

git mergetool 

:and then hit return as prompted, and the filemerge window opens showing all the merge conflicts, it only responds to the commands cmd+D and cmd+shift+D (which allow cycling through the conflicts). However, there doesn't seem to be a mention of how to, for each conflict, choose left/right/neither. The combo-box dropdown does not seem to do anything.

Have already looked at docs, guide, file system menu, and systematically pressed keys on the keyboard looking for a response =)

ArtOfWarfare
  • 17,763
  • 14
  • 122
  • 177
xxjjnn
  • 12,522
  • 19
  • 52
  • 77
  • I'm getting a hunch that filemerge only shows the errors, and the way you fix them is manually with your own text editor. ie you aren't supposed to be able to edit things with filemerge. – xxjjnn Nov 02 '12 at 09:54
  • @ClothSwort No, editing works fine in the bottom FileMerge window. – Quantum7 Jul 02 '13 at 20:54

1 Answers1

117

I haven't found any official documentation for it, but here's the understanding I got from trial and error:

There's a split view with your two options on the left and right. You can't edit either of those. There's also a bottom view which you can edit. You might need to pull up on the little circle in the middle of the bottom of the screen to expand that section.

For each conflict, click on the area in middle of the left/right split view and choose from the drop down in the lower right either "Choose Left" if the left is what you want or "Choose Right" if that is what you want. If neither option is good, click "Choose Neither" and edit it in the bottom section.

There's an arrow in the middle column that will show whether you've chosen left or right by pointing at it. If you've chosen neither, the arrow will disappear. All three views scroll together using the scroll bar on the far right screen.

When you're done, click File > Save Merge from the menubar.

ArtOfWarfare
  • 17,763
  • 14
  • 122
  • 177
  • 21
    Thanks for the pointers: it's a woefully unintuitive tool. The bottom panel was a great discovery. I found the best way to navigate to the next conflict was using the up/down arrow keys. – Michael Kay Aug 14 '14 at 22:17
  • 7
    Good call on the tiny circle located at the bottom ... didn't even notice it until reading your posting. Thanks. – BonanzaDriver Dec 03 '14 at 00:00
  • 5
    Ah! The dragging the little circle up was what got me too. – Don Mar 04 '15 at 23:41
  • 5
    Something that confused me for a while: After you update the file to how you want it, or finish resolving the conflicts, you have to actually quit FileMerge to get the `git mergetool` to advance – Garrett Jan 08 '16 at 17:40
  • 4
    Thanks @ArtOFWarfare ! Also wanted to add that if multiple files have conflicts, you have to save the merge, then quit the FileMerge program before the git merge tool will go to the next file and open it up in FileMerge. – user3236990 Jan 17 '17 at 02:40
  • how do u jump to the next conflicted file after finishing merging one? – Aero Wang Jun 15 '17 at 02:21
  • 1
    And where does it save this merge, into the left or the right? It's not at all clear from the labels. My _guess_ is left, but it should be documented here. – codehearted Aug 17 '18 at 21:40
  • After I merge all the files and they have checkmarks, it still doesn't show the folders that contain them as merged, how do I mark those as merged without bluntly choosing left or right for the whole folder? – codehearted Aug 17 '18 at 21:59
  • This is so handy - thanks! I can see why they have chosen to use drop-downs, in order to fit more options without polluting the screen, but it is so unintuitive. Your explanation is awesome. – keldar Aug 21 '18 at 13:36
  • Anyone understood if the merge is saved to left or right? as @codehearted asked. – Keerthi Polepalle Feb 21 '19 at 11:15