2016-11-10 97 views
0

打开比较工具当我在终端中的“git pull”,这有时会导致一个合并冲突。Git会不会在终端

我试图设置使用这些冲突默认比较工具:

git config --global merge.tool opendiff 

如果我输入端子opendiff file1.txt file2.txt手动它的工作原理,但它对于合并冲突确实自动工作。

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

我缺少的一个步骤设置一个默认的合并工具?

+0

会http://stackoverflow.com/q/13719122/6309帮助吗? – VonC

回答

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,这应该已经是这样了),我测试了这个在OSX 10.10

+0

是,打开了opendiff当我在终端直接输入,所以它必须在我的$路径。 – Kokodoko

0

。 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 

然后模拟d在新创建的git仓库中发生合并冲突。在此之后一个git mergetool开辟了差异的工具,没有任何问题:

enter image description here

您能查看您的合并工具是被设置正确:

enter image description here

我与另一个合并工具git config --global merge.tool bc3再次测试此通过执行以下操作:

git config --list --show-origin 

如果不提供线索的问题,那么这里就是详细输出可能持有更多的线索:

$ 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' 
+0

混帐配置--list - 显示,起源给出了错误:不明选项:“秀原产地” – Kokodoko

+0

什么标志启用详细输出git的合并工具......当我的比较,也输出告诉你一些事情? –

+0

谢谢。什么是快速模拟合并冲突的最佳方式?我不确定它现在是否正在工作或不是:) – Kokodoko