27

In.gitconfig file I setup up the git diff as follows:

[diff]
    tool = kdiff3

[difftool "kdiff3"]
    path = path_directory/kdiff3.app

In this setting kdiff is not accessible and I get the following error when I run in terminal

>> git difftool
The diff tool kdiff3 is not available as 'Kdiff_local_software_path/kdiff3.app'
fatal: external diff died, stopping at modified_file

Do you have any suggestion I can fix this issue ? In my current setup Mac OS 10.10.5 git diff tool is git merge tool that I want to replace with kdiff.

4
  • Is kdiff3 installed?
    – hjpotter92
    Nov 15, 2015 at 17:26
  • @hjpotter92 It is not installed. I unarchive the dmg file in my local directory
    – J4cK
    Nov 15, 2015 at 17:39
  • @DaveNewton OS X 10.10.5 question updated
    – J4cK
    Nov 15, 2015 at 17:40
  • 1
    No worries, it just caught me off-guard :) Nov 15, 2015 at 17:41

6 Answers 6

29

kdiff3 is generally located at the following location:

/Applications/kdiff3.app/Contents/MacOS/kdiff3

so, try

[difftool "kdiff3"]
    path = /Applications/kdiff3.app/Contents/MacOS/kdiff3

If you installed kdiff using brew, then you'd not need the difftool parameter in config for git 1.8 onwards. Just the following would work:

[diff]
    tool = kdiff3

If you installed kdiff mounting the dmg file to kdiff.app then set your local path as following:

[difftool "kdiff3"]
    path = directory_path_where_you_installed/kdiff3.app/Contents/MacOS/kdiff3
3
  • I have not installed with brew. I have kdiff3.app in my local directory. The problem is if I set my local path it can not find the path. Do you have any suggestion regarding setup the local kdiff3.app path location ?
    – J4cK
    Nov 15, 2015 at 17:37
  • 2
    @J4cK Update the path to reflect the actual location of kdiff3.app/Contents/MacOS/kdiff3.
    – hjpotter92
    Nov 15, 2015 at 17:41
  • for those who have installed kdiff3 with dmg and having kdiff3: not found it may help to add this symbolik link: ln -s /Applications/kdiff3.app/Contents/MacOS/kdiff3 /usr/local/bin/kdiff3
    – Sasha
    Feb 9, 2021 at 10:39
14
  1. Download kdiff3 and install as app(drag and drop the kdiff3 into your Applications): http://sourceforge.net/projects/kdiff3/files/kdiff3/0.9.98/kdiff3-0.9.98-MacOSX-64Bit.dmg/download

  2. Setup git config tool as following, works for me on MacBook Pro:

git config --global merge.tool kdiff3

and:

git config --global mergetool.kdiff3.cmd '/Applications/kdiff3.app/Contents/MacOS/kdiff3 $BASE $LOCAL $REMOTE -o $MERGED'

4
  • This didn't help for me. Jul 23, 2018 at 6:13
  • I checked that /Applications/kdiff3.app/Contents/MacOS/kdiff3 actually exists, so that cannot be the problem. I tried to edit in the .gitconfig file, but that is reset each time I start Sourcetree, so that doesn't help. Any ideas? Jul 23, 2018 at 6:26
  • Worked for me ¯_(ツ)_/¯ Aug 2, 2018 at 2:16
  • 3
    This works + going to System Preferences -> Security & Privacy -> General -> press the button to open kdiff3 anyway if you hit a security error trying to open it.
    – rtaft
    May 20, 2021 at 14:49
11
  1. First check whether kdiff3 is installed and recognized by git:

    $ type -a kdiff3
    -bash: type: kdiff3: not found
    

    In cases where kdiff3 is not installed in macOS, git will also show following messages:

    $ git difftool --tool-help
    $ # OR (both command would do)
    $ git mergetool --tool-help
    'git mergetool --tool=<tool>' may be set to one of the following:
            emerge
            opendiff
            vimdiff
            vimdiff2
            vimdiff3
    
    The following tools are valid, **but not currently available**:
            ...
            gvimdiff3
            kdiff3
            meld
            ...
    
    Some of the tools listed above only work in a windowed
    environment. If run in a terminal-only session, they will fail.
    

  1. Then we should install kdiff3, there are many ways to do it:

    I personally prefer MacPort:

    $ port search kdiff3
    kdiff3 @0.9.98_4 (devel)
        kdiff3 is a file comparing and merging tool.
    $ sudo port install kdiff3
    ...installing process...
    

    After this, kdiff3 should be available to macOS and git

    $ type -a kdiff3
    kdiff3 is /opt/local/bin/kdiff3
    $ git difftool --tool-help
    'git difftool --tool=<tool>' may be set to one of the following:
            emerge
            kdiff3
            opendiff
            ...
    

  1. Finally, make sure the correct configuration for git:

    [diff]
        tool = kdiff3
    [difftool]
        prompt = false
    [merge]
        tool = kdiff3
        conflictstyle = diff3
    
2
  • 1
    for those who have installed kdiff3 with dmg and having kdiff3: not found it may help to add this symbolik link: ln -s /Applications/kdiff3.app/Contents/MacOS/kdiff3 /usr/local/bin/kdiff3
    – Sasha
    Feb 9, 2021 at 10:43
  • There seems to be a problem when installing on M1 Macs: Error: Cannot install kdiff3 for the arch 'arm64' because Error: its dependency qt4-mac only supports the archs 'ppc ppc64 i386 x86_64'. May 11, 2022 at 4:30
6

You don't need to add any paths to your gitconfig as described in the other answers. This is all you need to configure in you .gitconfig

[diff]
    guitool = kdiff3
[merge]
    tool = kdiff3

Assuming you have homebrew installed on your machine:

brew update
brew tap caskroom/cask
brew cask install kdiff3

Explanation:

  1. setup to use cask

    brew tap caskroom/cask
    
  2. downloads kdiff3, moves it to your Applications dir and links kdiff3.sh to /usr/local/bin/kdiff3

    brew cask install kdiff3
    
2
1

Here are updated commands if you are installing kdiff3 using brew

brew tap homebrew/cask

brew install kdiff3 --cask

0

Just to add my 5 cents to this answer if you do not have homebrew follow these steps from appstore official site it will take a few minutes to download and install all the necessary packages.

After running the second step you need to follow the instructions that the terminal shows you after everything was downloaded and installed(there are 3 more steps to execute in the terminal).

In source tree then you will be able to select kdiff3 as the default diff merge tool.

If running the merge tool program for the first time you might need to execute it from the applications folder yourself by right clicking the file and select the open option in order to give the diff tool app the necessary permission to be executed every time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.