Visual diff tools (optional)
Visual diff tools allow to visualize differences between files side by side. They can be used independently of version control but when coupled with Git, they can provide a nice alternative to command line output to show differences between file versions or branches.
On Windows we recommend the program meld. Please follow installation instructions from http://meldmerge.org.
This is how you can configure Git to open Meld when doing git difftool
:
$ git config --global diff.tool meld
$ git config --global mergetool.meld.path "C:\Program Files (x86)\Meld\Meld.exe"
For meld version 3.20.3, because of reasons discussed here, you can have multiple “Could not create key” errors that you can get around by clicking ‘Ignore’.
Then, to open Meld when doing git difftool
:
$ git config --global diff.tool meld
$ git config --global mergetool.meld.path "$LOCALAPPDATA\Programs\Meld\Meld.exe"
For macOS we recommend to use Opendiff. You can install it following this blog post.
On Linux we recommend the program meld. Install meld via your distribution package manager. For Debian/Ubuntu run:
$ sudo apt-get install meld
For Fedora:
$ sudo dnf install meld
This is how you can configure Git to open Meld when doing git difftool
:
$ git config --global diff.tool meld
How to verify the installation
To test it create two text files which are similar and then compare them with Meld or Diffuse or Opendiff (or the tool which you have chosen above for visual differences):
$ meld file1 file2
or:
$ diffuse file1 file2
or:
$ opendiff file1 file2
You should now see both versions side by side.
To test launching Meld through Git, move into a folder that contains two or more files and instruct Git to compare files.
For example, to see the difference between file1.txt
and file2.txt
:
$ git difftool --no-index file1.txt file2.txt