How to setup kdiff3 in Mac OS?

后端 未结 4 418
再見小時候
再見小時候 2020-12-24 13:51

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

[diff]
    tool = kdiff3

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


        
4条回答
  •  我在风中等你
    2020-12-24 14:14

    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=' 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:

      • by using MacPort
      • by using Homebrew
      • by downloading SourceForge dmg package
      • building from source
      • etc.

      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=' 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
      

提交回复
热议问题