问题描述
通常 git -c merge.tool = gvimdiff mergetool
以批处理模式打开要合并的文件:
'...'的正常合并冲突:
{local}:修改文件
{remote}:修改文件
4个文件到编辑
...似乎没有变化。
合并成功了吗? [y / n] n
合并...失败
继续合并其他未解析的路径(y / n)? y
'...'的正常合并冲突:
{local}:已修改文件
{remote}:已修改文件
要编辑
模块的4个文件..似乎没有改变。
合并成功了吗? [y / n] n
模块合并...失败
继续合并其他未解析的路径(y / n)? n
如何使它打开所有文件,并带有选项卡(如 gvim -p file1 file2
),它包含要合并的每个文件的四个窗格排列? git mergetool flow旨在一次解决一个文件中的冲突。因此,你所要求的不能以一种干净的方式来完成。但是可以创建一个自定义的mergetool,它将在 gvim
窗口中累积来自 git mergetool
的输入。这个解决方案不可避免地要包含的窍门是,它必须让 git mergetool
流认为自定义mergetool已成功合并文件,即使它刚打开gvim中的文件。这是必须的,这样 git mergetool
流程才会进入下一个文件,而不会提出任何问题。因此,如果您退出gvim而未做任何更改,git仍然会认为所有冲突都已解决。
此类自定义mergetool的草稿版本(即打开文件在不同的gvim窗口中,而不是在标签页中):
.gitconfig :
[mergetoolmygvimdiff]
cmd = / path / to / mygvimdiff$ MERGED$ LOCAL$ BASE$ REMOTE
trustExitCode = true
mygvimdiff :
#!/ bin / bash
gvim -d -cwincmd J$ @
#等到gvim在
之前加载临时文件#git mergetool脚本删除它们
sleep 1
exit 0
使用:
git mergetool -t mygvimdiff
Normally git -c merge.tool=gvimdiff mergetool
opens files to be merged on by one, in batch mode:
Normal merge conflict for '...':
{local}: modified file
{remote}: modified file
4 files to edit
... seems unchanged.
Was the merge successful? [y/n] n
merge of ... failed
Continue merging other unresolved paths (y/n) ? y
Normal merge conflict for '...':
{local}: modified file
{remote}: modified file
4 files to edit
modules ... seems unchanged.
Was the merge successful? [y/n] n
merge of modules ... failed
Continue merging other unresolved paths (y/n) ? n
How do I make it open all files at one, with tabs (like in gvim -p file1 file2
) that contain the four pane arrangement for each file to be merged?
git mergetool
flow is designed to resolve conflicts in one file a time. Hence what you are asking for cannot be done in a clean way. However it is possible to create a custom mergetool, that will accumulate input from git mergetool
in a single gvim
window. The hack that this "solution" inevitably has to contain is that it must make the git mergetool
flow believe that the custom mergetool has successfully merged the file, even though it just has opened the file in gvim. This is necessary so that the git mergetool
flow proceeds to the next file without asking any questions. As a result, if you exit gvim without making any changes, git will still think that all conflicts have been resolved.
A draft version of such a custom mergetool (that opens files in different gvim windows, rather than in tabs) follows:
.gitconfig:
[mergetool "mygvimdiff"]
cmd=/path/to/mygvimdiff "$MERGED" "$LOCAL" "$BASE" "$REMOTE"
trustExitCode=true
mygvimdiff:
#!/bin/bash
gvim -d -c "wincmd J" "$@"
# wait till gvim loads the temporary files before
# the git mergetool script deletes them
sleep 1
exit 0
Usage:
git mergetool -t mygvimdiff
这篇关于如何使gvimdiff通过git mergetool打开所有文件一次在标签中打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!