-->

如何使用了opendiff作为默认的合并工具(How to use opendiff as defa

2019-07-04 13:16发布

嗨,我尝试使用了opendiff作为git的合并工具,但是当我运行合并工具我收到此错误信息:

合并工具了opendiff不作为“了opendiff”

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

Answer 1:

你需要了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

如果得到Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo ,打开Xcode和接受许可修复该问题



Answer 2:

请确保你已经安装了XCode。 (如果你使用Git,那么你可能使用BREW,在这种情况下,你可能已经安装的XCode。)

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

$ git mergetool -t opendiff

至于设立了opendiff为默认工具,你需要设置“merge.tool”变量使用Git的配置文件。



Answer 3:

git的支持--dir-DIFF(-d)执行目录比较,这看起来很不错FileMerge。 然而,在使用了opendiff与--dir-DIFF几个小问题。 了opendiff没有--merge预定目标,并git会过早地删除临时文件保存更改。 我的解决办法是使用一个小的bash脚本调用FileMerge。 我把它叫做gdiff

#!/bin/bash
# find top level of git project
dir=$PWD
until [ -e "$dir/.git" ]; do
  if [ "$dir" == "/" ]; then
    echo "Not a git repository" >&2
    exit 1;
  fi
  dir=`dirname "$dir"`
done
# open fresh FileMerge and wait for termination
open -a FileMerge -n -W --args -left "$1" -right "$2" -merge "$dir"

https://gist.github.com/miner/e73fc98a83a8fe05d9ef000d46d68a9f

这样称呼它:

git difftool -d -x gdiff



文章来源: How to use opendiff as default mergetool