我使用的是CLI mergetool vimdiff,而不是逐行输入:diffg RE来选择远程版本,有没有一种方法可以让整个文件的远程版本作为目标合并?
发布于 2019-03-31 21:20:44
简短的回答:
使用:%diffget获取所有块。
解释:
与大多数vim命令一样,diffget接受一个范围。引用vimhelp:
:diffg :diffget
:[range]diffg[et] [bufspec]
Modify the current buffer to undo difference with another
buffer. [...]
See below for [range].
[...]
When no [range] is given, the diff at the cursor position or just above it is
affected. When [range] is used, Vim tries to only put or get the specified
lines.当用作范围时,%是“等于1,$(整个文件)”,请参见:help :%。
发布于 2019-03-30 19:52:23
(CLI替代)
我知道它并没有真正回答你的问题,但是如果你需要的是在一个合并的中从一个特定的冲突文件获取所有的东西,你甚至不需要一个工具。
您可以检出所需的文件版本(检查文档here和there),然后使用add来解决冲突:
git checkout --ours path/to/file
# or
git checkout --theirs path/to/file
# and then to conclude the resolution
git add path/to/file请注意,如果您对此移动感到遗憾,也可以使用冲突标记将其恢复到未合并状态,使用
git checkout -m path/to/file发布于 2019-04-01 15:53:41
在mergetool中,如果你有2个以上的buffers,你就不能使用:diffget,因为Vim不知道从哪个文件得到diff。
但是,当您解决冲突时(您需要运行mergetool ),您需要使用Git创建的一些文件来管理冲突:
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: my/conflicting/file.py
Untracked files:
(use "git add <file>..." to include in what will be committed)
.env
my/conflicting/file.py.orig
my/conflicting/file_BACKUP_5038.py
my/conflicting/file_BASE_5038.py
my/conflicting/file_LOCAL_5038.py
my/conflicting/file_REMOTE_5038.py它们代表了冲突的不同方面:
因此,您可以做的就是将_REMOTE_文件复制为您当前的(cp path/to/file_REMOTE_* path/to/file),或者在mergetool中,复制_REMOTE_ (:%y)的内容并用它替换您的文件的内容(ggVGp,转到顶部,转到可视行模式,转到末尾,粘贴)。
https://stackoverflow.com/questions/55429485
复制相似问题