Git不会在终端打开diff工具

时间:2016-11-10 12:43:27

标签: git macos merge

当我做{' git pull'在终端中,这有时会导致合并冲突。

我尝试使用以下方法为这些冲突设置默认差异工具:

git config --global merge.tool opendiff

如果我在终端中手动输入opendiff file1.txt file2.txt,则可以正常工作,但会自动解决合并冲突。

相反,在合并冲突之后,VI文本编辑器会打开,但这不会显示实际的冲突 - 只有一个屏幕,您可以在其中填写提交消息。

我是否错过了设置默认合并工具的步骤?

2 个答案:

答案 0 :(得分:0)

检查更完整的merge.tool定义是否会更好:

git config --global merge.tool opendiff
git config --global mergetool.opendiff.cmd 'opendiff -merge "$MERGED" "$LOCAL" "$REMOTE"'
git config --global mergetool.opendiff.trustExitCode false

(并确保opendiff在您的$PATH中,已经是这种情况了。

答案 1 :(得分:0)

我使用以下命令在OSX 10.10.x上对此进行了测试(在此之前我的mergetool设置为其他内容):

# 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

然后在新创建的git repo上模拟合并冲突。在此之后git mergetool打开了diff工具,没有任何问题:

enter image description here

我使用另一个mergetool git config --global merge.tool bc3再次测试了这个:

enter image description here

通过执行以下操作,您是否可以检查您的mergetool是否正确设置:

git config --list --show-origin

如果这没有提供问题的线索,那么这里的VERBOSE输出可能包含更多线索:

$ GIT_CURL_VERBOSE=1 GIT_TRACE=2 git mergetool
+zbell_begin:1> zbell_timestamp=1478783158
+zbell_begin:2> zbell_lastcmd='GIT_CURL_VERBOSE=1 GIT_TRACE=2 git mergetool'
+iterm2_preexec:2> PS1='
%F{135}%n%f at %F{166}%m%f in %F{118}%~%f ${vcs_info_msg_0_}
$python_info[virtualenv]$ '
+iterm2_preexec:3> ITERM2_SHOULD_DECORATE_PROMPT=1
+iterm2_preexec:4> iterm2_before_cmd_executes
+iterm2_before_cmd_executes:1> printf '\033]133;C;\007'
+-zsh:70> GIT_CURL_VERBOSE=1 GIT_TRACE=2 git mergetool
13:05:58.178595 git.c:562               trace: exec: 'git-mergetool'
13:05:58.179015 run-command.c:336       trace: run_command: 'git-mergetool'
13:05:58.189681 git.c:562               trace: exec: 'git-sh-i18n--envsubst' '--variables' 'usage: $dashless $USAGE'
13:05:58.190101 run-command.c:336       trace: run_command: 'git-sh-i18n--envsubst' '--variables' 'usage: $dashless $USAGE'
13:05:58.196721 git.c:562               trace: exec: 'git-sh-i18n--envsubst' 'usage: $dashless $USAGE'
13:05:58.197349 run-command.c:336       trace: run_command: 'git-sh-i18n--envsubst' 'usage: $dashless $USAGE'
13:05:58.211241 git.c:349               trace: built-in: git 'config' '--bool' 'mergetool.prompt'
13:05:58.214550 git.c:349               trace: built-in: git 'rev-parse' '--git-dir'
13:05:58.218507 git.c:349               trace: built-in: git 'rev-parse' '--git-path' 'objects'
13:05:58.231731 git.c:349               trace: built-in: git 'config' 'merge.tool'
13:05:58.236048 git.c:349               trace: built-in: git 'config' 'mergetool.opendiff.cmd'
13:05:58.240211 git.c:349               trace: built-in: git 'config' '--bool' 'mergetool.keepBackup'
13:05:58.245948 git.c:349               trace: built-in: git 'config' '--bool' 'mergetool.keepTemporaries'
13:05:58.250250 git.c:349               trace: built-in: git 'rev-parse' '--show-toplevel'
13:05:58.254733 git.c:349               trace: built-in: git 'ls-files' '-u'
Merging:
another-file

13:05:58.259422 git.c:349               trace: built-in: git 'ls-files' '-u' '--' 'another-file'
13:05:58.265199 git.c:349               trace: built-in: git 'config' '--bool' 'mergetool.writeToTemp'
13:05:58.268606 git.c:349               trace: built-in: git 'ls-files' '-u' '--' 'another-file'
13:05:58.273569 git.c:349               trace: built-in: git 'ls-files' '-u' '--' 'another-file'
13:05:58.280265 git.c:349               trace: built-in: git 'ls-files' '-u' '--' 'another-file'
13:05:58.318106 git.c:349               trace: built-in: git 'rev-parse' '--show-cdup'
13:05:58.350195 git.c:349               trace: built-in: git 'rev-parse' '--show-cdup'
Normal merge conflict for 'another-file':
  {local}: created file
  {remote}: created file
13:05:58.356881 git.c:349               trace: built-in: git 'config' 'mergetool.opendiff.cmd'
13:05:58.361075 git.c:349               trace: built-in: git 'config' 'mergetool.opendiff.path'
13:05:58.365342 git.c:349               trace: built-in: git 'config' 'mergetool.opendiff.cmd'
13:05:58.370113 git.c:349               trace: built-in: git 'config' 'mergetool.opendiff.cmd'