问题描述
当我遇到冲突时,我尝试使用 git-mergetool
来解决它。我输入:
When I met a conflict, I tried to use git-mergetool
to solve it. I typed:
>git mergetool -t vimdiff
它以4路而不是3路方式打开 vimdiff
。 vimdiff中的分割窗口如下所示:
It opened vimdiff
in 4-way, not 3-way. My split windows in vimdiff look like:
:ls
1 #a "Gemfile.lock" line 1
2 %a "Gemfile.lock.LOCAL.4828.lock" line 1
3 a "Gemfile.lock.BASE.4828.lock" line 0
4 a "Gemfile.lock.REMOTE.4828.lock" line 0
它们是什么?我想要一个3路diff:目标文件,合并文件和工作文件。如何配置我的git或vimdiff?
What are they? I want a 3-way diff: target file, merge file and working file. How should I configure my git or vimdiff?
推荐答案
作为替代方案,您是否考虑过使用?
As an alternative, have you thought about using fugitive?
有一个很棒的vimcast, a href =http://vimcasts.org/episodes/fugitive-vim-resolving-merge-conflicts-with-vimdiff/ =noreferrer> Fugitive.vim - 解决与vimdiff的合并冲突,by德鲁尼尔。这是关于逃犯的系列文章的一部分。
There is a an excellent vimcast, Fugitive.vim - resolving merge conflicts with vimdiff, by Drew Neil. This is part of a series on fugitive.
网站是了解vim更多信息的好地方。
The Vimcasts website is a good place to learn more about vim.
要使用合并工具,您可以使用以下代码。
To use fugitive as you mergetool you can use the following.
git config --global mergetool.fugitive.cmd 'vim -f -c "Gdiff" "$MERGED"'
git config --global merge.tool fugitive
注意:您可能需要将 vim
更改为 mvim
或 gvim
。
Note: you may want to change vim
to mvim
or gvim
.
逃犯还有更多提供的不仅仅是一个合并工具脚本,因此请确保您阅读文档和/或查看vimcast。
Fugitive has a lot more to offer than just being a merge tool script so make sure you read the documentation and/or check out the vimcasts.
这篇关于为什么git mergetool会在vimdiff中打开4个窗口? (我预计3)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!