FileMerge 在从 SourceTree 启动后立即退出

FileMerge quits immediately after launching from SourceTree

我经常使用 Atlassian SourceTree(在 Mac OS X 上)启动 FileMerge 来解决 git 合并冲突。它突然停止工作:当我右键单击并 select Resolve Conflicts > Launch External Merge Tool 时,FileMerge 启动,创建它的中间文件,然后立即退出。 SourceTree 将其解释为合并过程已完成。

有什么问题,我该如何debug/fix?

我注意到之前的问题“SourceTree filemerge quits immediately and creates 4 files. How to fix it?”没有解决这个特定的场景(其中之一,它在标题中说 FileMerge 退出,但在 body 中它说 FileMerge 显示 /dev/null 作为面板之一。此外,我的合并冲突不是由于删除的文件造成的。)

如果 Xcode 最近自行更新,您可能需要同意新的许可条款。如果您不同意许可条款,FileMerge(从 SourceTree 启动时)将立即退出。

要检查这一点,请以常用用户身份打开 shell 和 运行:

$ opendiff

如果许可证有问题,它会告诉你。要同意新的许可条款,您需要 运行 使用 sudo:

打开 diff
$ sudo opendiff

同意许可条款后,您现在可以使用 Resolve Conflicts > Launch External Merge Tool 重新尝试从 SourceTree 启动 FileMerge。 FileMerge 应该启动并正常运行。

为了诊断问题,我从终端 运行 opendiff。我收到以下错误:

xcode-select: error: tool 'opendiff' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance

求解:

  1. 打开 Xcode > 首选项 > 位置
  2. 单击 命令行工具 和 select 您当前的 Xcode 版本旁边的下拉框。 (这对我来说是空的,因为我最近在新的 Mac 上安装了 Xcode。)

    再次进入Terminal
  1. 运行 opendiff,应该不会再出现上面的错误了。

现在,当您单击 启动外部合并工具 时,FileMerge 将从 SourceTree 正确打开。

对我来说,SourceTree 甚至没有启动 FileMerge。单击 启动外部合并工具 时没有任何反应。

此外,运行 opendiff 在终端中按预期工作:

$ opendiff
opendiff[64176:5561154] too few arguments
opendiff[64176:5561154] usage: opendiff file1 file2 [-ancestor ancestorFile] [-merge mergeFile]

对我有帮助的是 手动配置 SourceTree 通过 opendiff 命令使用 FileMerge,参数如下:$LOCAL $REMOTE -ancestor $BASE -merge $MERGED

这样,SourceTree 将按预期打开 FileMerge。

这也适用于解析消息 "xcode-select: error: tool 'opendiff' requires Xcode, but active developer directory '/Library/Developer/CommandLineTools' is a command line tools instance":

sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

这有助于: https://gist.github.com/kylefox/4512777

当 Xcode 实用程序运行时告诉系统:

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

将"opendiff"设置为全局默认合并工具:

git 配置 --global merge.tool opendiff

我遇到过这个问题,答案已经解决
所以这一次,当我再次遇到它时,我认为同样的问题发生了......

尝试将近一个小时后,我发现 Diffmerge(或任何外部差异工具)没有打开,因为 没有文件在当前分支合并.

当您执行 Cherry Pick 时,可能会发生这种情况,其中提交可能会跳动。添加此答案以提醒将要遇到相同问题的人。

勾选Allow Sourcetree to modify your global...为我解决了问题