Recently while working on tight scheduled project, I came across a scenario where I was having two huge files with very subtle differences in the content. Consider it like your log files. Now, both of them were present locally and unfortunately not being tracked by any kind of version control system (Git, SVN, etc).

Now, I needed to find the differences between these two files and work accordingly.

Finally, I found an efficient solution using the OpenDiff tool.

Following is my short explaination on what this tool does and how you can leverage its features efficiently.

Firstly, What is Opendiff?

Well, Mac(OS X) comes with a utility tool called opendiff. However, it assumes that you should have Xcode installed as it provides FileMerge feature. The FileMerge is responsible for comparing, differentiating and merging any text document.

opendiff

Uses FileMerge internally to graphically compare or merge files/directories as:

opendiff file1 file2         # compare two files

or

opendiff dir1 dir2           # compare two directories

It launches the GUI with Diff that looks something like this:

alt text

To get more help, you can check the OpenDiff manual using man opendiff command on the terminal.

difftool

We all know the importance of Git. However, you can enhance it more by making opendiff tool as default git difftool.

You can do it simply by running following command:

git difftool --tool=opendiff

or

git config --global diff.tool opendiff

You can get the associated help using following command:

git difftool --tool-help

mergetool

The adventure has not yet ended. Alongwith above customization, you can set it as your default merge tool. Get help for this mergetool using:

git mergetool --tool-help

References