views:

13631

answers:

16

Title says it. What's the best tool for viewing and editing a merge in Git? I'd like to get a 3-way merge view, with "mine", "theirs" and "output" in separate panels.

Also, instructions for invoking said tool would be great. (I still haven't figure out how to start kdiff3 in such a way that it doesn't give me an error)

edit: My OS is Ubuntu.

+9  A: 

My favorite visual merge tool is the free SourceGear DiffMerge, available for Windows, Linux and MacOS. Clean visual UI with all diff features you'd expect, command line interface and usable keyboard shortcuts.

Luke
+21  A: 

Meld is a good diff/merge tool.

Edit: Here's an article on it.

No windows version as far as I can tell, and doesn't use a 3 way view which means you don't get a preview of the final version.
Luke
It does indeed have a 3 way view, and the original poster is running Linux, not Windows, so I don't see why that's a problem.
+2  A: 

I hear good things about kdiff3, seems to be between that and meld (which another poster already suggested).

+6  A: 

If you are just looking for a diff tool beyond compare is pretty nice: http://www.scootersoftware.com/moreinfo.php

Nathan Feger
A: 

Okay, I figured out how to invoke these great tools, and that's with the very helpful command "git mergetool"

(Previously, I was trying to do the job myself, with a script that made temporary copies of the file and then called the tool. That was silly.)

andy
Agree with peter below ... how do I get `git mergetool` to work?
Lanny
I've been wondering what I had to do in order to make gvimdiff work with git, and now I find out the answer is "nothing"! I'd vote this answer up if it included the information in Paul's comment on peter's question below.
Sam Stokes
A: 

Okay, I figured out how to invoke these great tools, and that's with the very helpful command "git mergetool"

That's very nice: can you please leave some instructions on how you did it?

Git supports vimdiff, gvimdiff, kdiff3, tkdiff, meld, opendiff, xxdiff, and emerge out of the box and you can install others: `git config merge.tool "your.tool"` will set your chosen tool and then `git mergetool` after a failed merge will show you the diffs in context.
Paul
+2  A: 

You can change the tool used by git mergetool by passing git mergetool -t=<tool> or --tool=<tool>. To change the default (from vimdiff) use git config merge.tool <tool>.

+1  A: 

Diffuse is my favourite but of course I am biased. :-) It is very easy to use:

$ diffuse "mine" "output" "theirs"

http://diffuse.sourceforge.net/

I really like diffuse, and I'm not biased.
total
A: 

gitx http://gitx.frim.nl/

Some bugs when working with large commit sets but great for browsing through changes and picking different changes to stage and then commit.

Blake Lucchesi
gitx only does diff, right?
knoopx
Not available under Ubuntu
analogue
+1  A: 

p4merge

Ron
+11  A: 

You can configure your own merge tool to be used with "git mergetool".

Example:

  git config --global merge.tool p4merge
  git config --global mergetool.p4merge.cmd p4merge '$BASE' '$LOCAL' '$REMOTE' '$MERGED'
  git config --global mergetool.p4merge.trustExitCode false

And while you are at it, you can also set it up as your difftool for "git difftool"

  git config --global diff.tool p4merge
  git config --global difftool.p4merge.cmd p4merge '$LOCAL' '$REMOTE'

Note that in unix/linux you don't want the $BASE to get parsed as a variable by your shell - it should actually appear in your ~/.gitconfig file for this to work.

Evgeny
P4Merge does it for me.
Benjol
A: 

Araxis Merge http://www.araxis.com/ I'm using it on Mac OS X but I've used it on windows... it's not free... but it has some nice features... nicer on windows though.

Also... I'm not very fond of the araxis git merge script... it exits with code zero "properly". This means that when you run git mergetool you don't have to say "yes" on the command line to the query "Was the merge successful?". This feature is great... if things go smoothly... if it's not... getting the file that was not successfully merged (e.g. some error happened) back into an unmerged state is something i have yet to discover how to do. So I modified there apple script araxisgitmerge to not wrap and return in a try catch statement so that I always have to answer yes to the query "Was the merge successful?"

Clint Modien
A: 

you can install ECMerge diff/merge tool on your Linux, Mac or Windows. It is pre-configured in Git, so just using git mergetool will do the job.

Armel
A: 

Beyond Compare 3, my favorite, has a merge functionality in the Pro edition. The good thing with its merge is that it let you see all 4 views: base, left, right, and merged result. It's somewhat less visual than P4V but way more than WinDiff. It integrates with many source control and works on Windows/Linux. It has many features like advanced rules, editions, manual alignment...

The Perforce Visual Client (P4V) is a free tool that provides one of the most explicit interface for merging (see some screen-shots and some more). Works on all major platforms. My main disappointement with that tool is its kind of "read-only" interface. You cannot edit manually the files and you cannot manually align.

SourceGear Diff/Merge may be my second free tool choice. Check that merge screens-shot and you'll see it's has the 3 views at least.

PS: P4Merge is included in P4V. Perforce tries to make it a bit hard to get their tool without their client.

Wernight
+1  A: 

vimdiff

Once you have have learned vim (and IMHO you should), vimdiff is just one more beautiful little orthogonal concept to learn. To get online help in vim:

:help vimdiff

If you're stuck in the dark ages of mouse usage, and the files you're merging aren't very large, I recommend meld.

Drew Wagner