How to use git mergetool's filemerge
Asked Answered
R

1

58

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

Renfroe answered 1/11, 2012 at 18:58 Comment(2)
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.Renfroe
@ClothSwort No, editing works fine in the bottom FileMerge window.Brim
F
125

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.

Fauteuil answered 29/10, 2013 at 15:46 Comment(11)
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.Sweated
Good call on the tiny circle located at the bottom ... didn't even notice it until reading your posting. Thanks.Furcula
Ah! The dragging the little circle up was what got me too.Whittier
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 advanceWinegar
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.Dearr
how do u jump to the next conflicted file after finishing merging one?Consuela
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.Kemerovo
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?Kemerovo
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.Fuss
Anyone understood if the merge is saved to left or right? as @Kemerovo asked.Hinckley
You get to choose where merged files are saved. The first time I try to save a file during new a merge, I get a You must specify a "merge directory" prompt. I chose the directory on the left, but it could also be a new directory.Didier

© 2022 - 2024 — McMap. All rights reserved.