How to use git mergetool's filemerge

xxjjnn picture xxjjnn · Nov 1, 2012 · Viewed 28.5k times · Source

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 =)

Answer

ArtOfWarfare picture ArtOfWarfare · Oct 29, 2013

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.