如何使用opendiff作为默认的mergetool

Cor*_*sum 18 git mergetool opendiff

嗨,我想使用opendiff作为git mergetool,但是当我运行mergetool时,我收到此错误消息:

合并工具opendiff不能用作'opendiff'

我究竟做错了什么?它之前工作正常,但由于我安装了一个新的硬盘,它不再工作了:(

Kev*_*ary 27

您需要将opendiff配置为全局merge.tool:

# locate xcode utilities
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

# set "opendiff" as the default mergetool globally
git config --global merge.tool opendiff
Run Code Online (Sandbox Code Playgroud)

如果你得到Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo,打开XCode并接受许可证就可以解决问题


cog*_*ell 16

确保安装了XCode.(如果您使用的是git,那么您可能正在使用brew,在这种情况下,您可能已经安装了XCode.)

一次性解决方案是告诉git你想要使用什么工具:

$ git mergetool -t opendiff
Run Code Online (Sandbox Code Playgroud)

至于将opendiff设置为默认工具,您需要在git配置文件中设置"merge.tool"变量.