23

I really hate visualizing diffs using the default UNIX diff tool. Is it possible to do view git diffs using a GUI tool that will nicely display the local and remote side-by-side, similar how it is possible to set the mergetool to be DiffMerge and when you do

git mergetool myfile.txt

it pops the DiffMerge GUI for easier visualization and merging? I am using OSX.

amphibient
  • 29,770
  • 54
  • 146
  • 240
  • For the Windows users coming here via Google: You can use kdiff3 as explained here: https://stackoverflow.com/q/33308482/873282 – koppor Feb 01 '18 at 07:36

6 Answers6

42

You could use opendiff. It is a command line tool which opens the GUI of FileMerge.

You could instruct Git to use it automatically for git-mergetool with:

git config --global merge.tool opendiff

If you want it for git-difftool as well:

git config --global diff.tool opendiff

And you could also disable the prompting for every file with:

git config --global difftool.prompt false

For more details type: git help config and search with / for the different options.


P.S. If you don't have opendiff installed you could install it together with the Developer Tools from Xcode: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/opendiff.1.html

UPDATE: In recent versions of Xcode, FileMerge is now bundled with Xcode. You cannot install FileMerge as a standalone program. opendiff is still in its command-line utilities which are standalone.

freya
  • 459
  • 7
  • 14
Haralan Dobrev
  • 7,617
  • 2
  • 48
  • 66
  • 1
    I followed what you suggested but when I type `git diff myfile.txt` nothing happens and I have no idea why. opendiff is working properly. Any ideas on what I can try? – aaragon Mar 23 '16 at 09:11
  • FileMerge doesn't seem to like non-ASCII files. – Flimm Nov 02 '16 at 18:07
  • 1
    @Flimm I've found this old article addressing the non-ASCII problem with FileMerge http://jasonfharris.com/blog/2010/07/filemerge-and-utf-8/ I hope it helps. – Haralan Dobrev Nov 02 '16 at 21:57
  • 1
    I ran `git config --global diff.tool opendiff` but still getting diff output in plain text on command line GUI – Parth Mar 26 '21 at 19:48
  • 1
    @ParthTamane, maybe you used "git diff ..." instead of "git difftool ..." to see the differences? I think you'll need to use "git difftool ..." to see the differences using opendiff. – Neal Young Feb 09 '22 at 14:37
2

P4Merge from Perforce is pretty good and the standalone P4Merge application is free. You can get it at http://www.perforce.com/product/components/perforce-visual-merge-and-diff-tools

Also, if you are using SublimeText than http://www.sublimerge.com/ is also a good tool.

Daniel Margol
  • 691
  • 6
  • 6
1

Even if you aren't using Python, having PyCharm installed is worth it for its great Git integration. It's a good general-purpose editor and has a good visual diff+merge tool. The merge tool includes a triple-pane interface with intuitive code block selection. The community edition is free and works on my installation of MacOS High Sierra.

Reinderien
  • 11,755
  • 5
  • 49
  • 77
1

I use BBEdit for this purpose. I think its diff display works very well. I have it set as my git external diff tool.

matt
  • 515,959
  • 87
  • 875
  • 1,141
0

If you use Visual Studio Code on your Mac, then you can install the Diff Folder extension to compare files and folders of checked out code.

Its very configurable - can exclude files based on regexp, open file diff to the side etc.

Its also easy to use !

Rohit
  • 439
  • 8
  • 18
-4

If you have the two different files, WinMerge does a very nice side-by-side comparison. I don't know if it's available for non-Windows platforms. Also, some systems will let you choose your own comparison tool, while others are hard coded to something specific -- I don't know about your Git environment.

Phil Perry
  • 2,126
  • 14
  • 18