Git difftool configuration

meld-mary As of Git 1.6.3 the difftool command was added to Git. This basically lets you use and external merge tool to view/edit your differences by running git difftool instead of the normal diff. I like using Meld, but it works with a bunch of merge tools. It was a bit confusing how to configure it, so here goes:

To figure out which ones you have installed and which are supported:

git difftool --tool-help

For me, the following works to set things up to use Meld without prompting.

sudo apt-get install meld
git config --global diff.tool meld
git config --global difftool.prompt false
git config --global merge.tool meld
git config --global mergetool.meld.cmd 'meld "$BASE" "$LOCAL" "$REMOTE" --output="$MERGED"'
# Or this one if you like the center pane to be the git conflict file
#git config --global mergetool.meld.cmd 'meld "$BASE" "$MERGED" "$REMOTE" --output="$MERGED"'

In Windows it is a bit more complicated, so it is probably easier to just edit the .gitconfig file.  This also adds the mergetool settings to use Meld.  I added the following to my configuration:

[diff]
	tool = meld
[difftool]
    prompt = false
[difftool "meld"]
	path = C:\\Program Files (x86)\\Meld\\Meld.exe
[merge]
    tool = meld
[mergetool "meld"]
    # Choose one of these 2 lines.  
    # It chooses which is the one being
    # edited (center pane).
    #cmd = \"C:\\Program Files (x86)\\Meld\\Meld.exe\" "$LOCAL" "$MERGED" "$REMOTE" --output "$MERGED"
    cmd = \"C:\\Program Files (x86)\\Meld\\Meld.exe\" "$LOCAL" "$BASE" "$REMOTE" --output "$MERGED"