The Linux Page

meld -- advanced graphical diff utility

Find the difference(s)

I used subversion and now git and once in a while I have a rather large number of changes to check in. In most cases, I can just do svn diff or git diff . and be done with it. But today I have changes in quite many files (12, I know, it's not that much, but still... when you're by yourself on a project...) and some of the changes were quite large.

To have something better than svn diff, I looked into the different graphical diff tools available a little while ago and I installed meld:

sudo apt-get install meld
meld .&

I think that's the best I can find under Linux at this point. In my situation I can simply open the SVN or git diff in the current directory and get all the changes I made in a simple list of files, double clicking gets me to the actual diff with colors and actions that you can take to resolve the diff (in case you needed to resolve anything.)

The tool proposes two arrows to instantely copy the changes from one side to the other. You can also just type as if in an editor and save your changes. It will also help you resolve conflicts if you have such. To my point of view, that's a very important tool to have on Linux.

Git Settings

It is possible to better integrat meld with git by using some git options like so:

[user]
    name = AlexisWilke
    email = alexis@example.com

[core]
    excludesfile = ~/.gitignore
    #whitespace = -trailing-space,-indent-with-non-tab,-tab-in-indent
[push]
    default = simple
[giggle]
    main-window-maximized = false
    main-window-geometry = 1114x789+144+184
    file-view-vpane-position = 389
    main-window-view = FileView
    history-view-vpane-position = 315
    file-view-hpane-position = 190
[branch]
    autosetupmerge = always
    autosetuprebase = always

[diff]
    tool = meld

#[url "ssh://git@github.com/"]
#    insteadOf = https://github.com/

As we can see, I have a [diff] section which says tool = meld.

This means you can now run a command such as:

git difftool -d branchname
git difftool -d stash
git difftool -d master..devel

The following are all the options you can use for diff-ing and merging your source with meld or some other tool:

[diff]
  tool = meld
[difftool]
  prompt = false
[difftool "meld"]
  trustExitCode = true
  cmd = open -W -a Meld --args \"$LOCAL\" \"$REMOTE\"
[merge]
  tool = meld
[mergetool]
  prompt = false
[mergetool "meld"]
  trustExitCode = true
  cmd = open -W -a Meld --args --auto-merge \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output=\"$MERGED\"

Source: View differences of branches with meld