先安装 Beyond Compare,我 Mac 上用的是 Version 4.2.3 (build 22587)。
再配置 Beyond Compare 命令行工具:Beyond Compare -> Install Command Line Tools -> 填写电脑密码 -> Successfully installed command line tools. -> OK。此时可以用 bcomp file1 file2 比较文件了。
最后配置 git 对比工具:
// Use bc3 on the command line for both BC version 3 and 4
// Diff Confirm that "bcompare" can be launched from Terminal. Then in a console window enter:
$ git config --global diff.tool bc3
$ git config --global difftool.bc3.trustExitCode true
// To launch a diff using Beyond Compare, use the command "git difftool file.ext".
// Merge Confirm that "bcompare" can be launched from Terminal. Then enter the following:
git config --global merge.tool bc3
git config --global mergetool.bc3.trustExitCode true
// To launch a 3-way merge using Beyond Compare, use the command "git mergetool file.ext".
// option
// git config --global difftool.prompt false
快在终端里键入 git difftool 看看效果吧。