30

How can I install Meld on MacOS, and then set it up as my difftool and mergetool in git?

SOLO
  • 868
  • 9
  • 19
Sivaram Yadav
  • 3,141
  • 3
  • 13
  • 15

3 Answers3

52
  1. Download the latest .dmg package for Mac from here: Meld for OSX

  2. Set meld as your git difftool/mergetool by editing your ~/.gitconfig and adding the following lines, as mentioned in the above link:

    [diff]
      tool = meld
    [difftool]
      prompt = false
    [difftool "meld"]
      trustExitCode = true
      cmd = open -W -a Meld --args \"$LOCAL\" \"$PWD/$REMOTE\"
    [merge]
      tool = meld
    [mergetool]
      prompt = false
    [mergetool "meld"]
      trustExitCode = true
      cmd = open -W -a Meld --args --auto-merge \"$PWD/$LOCAL\" \"$PWD/$BASE\" \"$PWD/$REMOTE\" --output=\"$PWD/$MERGED\"
    
  3. Use the git difftool command in your repo to compare and edit files between revisions.

SOLO
  • 868
  • 9
  • 19
vagavan
  • 625
  • 5
  • 8
  • 2
    I get meld command not found. How did you get meld into /usr/local/bin? – techguy2000 Jan 12 '19 at 19:56
  • `$PWD` part was missing for me, it seems it was not needed before. Thanks! – Bruno Medeiros Jul 14 '19 at 18:17
  • 2
    git diftool sometimes gives you relative and sometimes absolute paths. Looks like Meld can't deal with this very well, so you need to do something like `\"$([[ "$REMOTE" == /* ]] && echo "$REMOTE" || echo "$PWD/$REMOTE")\"` – pcv Dec 02 '19 at 08:59
22

From Mac OS High Sierra (10.13.6), Git 2.12.2

Install Meld

brew tap homebrew/cask

brew cask install meld

Set Meld as Git Mergetool

git config --global merge.tool meld

git config --global diff.guitool meld

Joey Morrow
  • 341
  • 2
  • 4
  • If you don't have brew installed, please follow directions here first: https://brew.sh/ – Joey Morrow Feb 07 '19 at 21:39
  • If you're on a corporate/firewalled network, be sure to set your http & https proxies. `export http_proxy=:` `export https_proxy=:` Then run the steps above. – Joey Morrow Feb 07 '19 at 21:40
  • For some reason, when I use the homebrew version of meld, meld will appear in the the dock, close, and then reopen but no meld windows will actually open; the icon will just sit in the dock doing nothing. – Alexej Magura May 10 '19 at 20:46
  • I have the same experience as Alexej Magura currently, and the suggested .gitconfig in other answers did not seem to work either – Colin D Sep 06 '19 at 01:01
  • 2
    For the second command, I have to use `brew install --cask meld` on Apple M1 – Higgs Feb 16 '21 at 10:52
11

Working solution starting from 2021

  • Operational System: Mac OS Big Sur (11.3.1)
  • Git: Git 2.30.1

Install

brew tap homebrew/cask
brew install --cask meld

Setup

git config --global merge.tool meld
git config --global  diff.guitool meld

Usage

git mergetool # When file conflicts happen during merge
Victor
  • 1,904
  • 18
  • 18