如何在Mac OS中设置kdiff3?

时间:2015-11-15 16:59:40

标签: git git-diff osx-leopard kdiff3 git-difftool

.gitconfig文件中,我按如下方式设置了git diff:

[diff]
    tool = kdiff3

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

在此设置中,无法访问kdiff,当我在终端中运行时,我收到以下错误

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

您有什么建议我可以解决这个问题吗?在我目前的设置中,Mac OS 10.10.5 git diff工具是git merge tool,我想用kdiff替换它。

4 个答案:

答案 0 :(得分:15)

kdiff3通常位于以下位置:

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

所以,试试

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

如果您使用kdiff安装了brew,那么您在配置git 1.8以后就不需要difftool参数了。只需以下方法即可:

[diff]
    tool = kdiff3

如果您安装kdiff将dmg文件挂载到kdiff.app,请将本地路径设置如下:

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

答案 1 :(得分:6)

  1. 下载kdiff3并安装为app(将kdiff3拖放到您的应用程序中): http://sourceforge.net/projects/kdiff3/files/kdiff3/0.9.98/kdiff3-0.9.98-MacOSX-64Bit.dmg/download

  2. 如下设置git配置工具,适用于MacBook Pro:

  3.   

    git config --global merge.tool kdiff3

      

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

答案 2 :(得分:3)

您不需要按照其他答案中的说明向gitconfig添加任何路径。 这就是您需要在.gitconfig中配置的所有内容

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

假设您在计算机上安装了自制软件:

brew update
brew tap caskroom/cask
brew cask install kdiff3

说明:

  1. 设置为使用酒桶

    brew tap caskroom/cask
    
  2. 下载kdiff3,将其移动到您的应用程序目录,并将kdiff3.sh链接到/ usr / local / bin / kdiff3

    brew cask install kdiff3
    

答案 3 :(得分:1)

  1. 首先检查kdiff3是否已安装并识别git

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

    在macOS中未安装kdiff3的情况下,git还将显示以下消息:

    $ 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. 然后我们应该安装kdiff3,有很多方法可以做到:

    我个人更喜欢MacPort

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

    此后,kdiff3应该可用于macOS和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. 最后,确保git的配置正确:

    [diff]
        tool = kdiff3
    [difftool]
        prompt = false
    [merge]
        tool = kdiff3
        conflictstyle = diff3