vimdiff 作为合并工具
vimdiff 有助于以图形方式显示两个文件的差异,并允许我们从左到右/从右到左选择更改。
我正在处理的文件是巨大的文件,除了少数之外,大多数差异 vimdiff 报告都可以自动合并。因为在 vimdiff 中逐个比较并采取操作需要花费大量时间。
我想知道 vimdiff 中是否有一个选项可以自动合并左右文件中的差异,只要没有歧义,并保留类似于 svn merge 和 cvs merge 工具的冲突解决方案?
vimdiff helps in showing the diff of two files graphically and allows us to pick the changes from left to right/right to left.
The files I am dealing with are huge files and most of the differences vimdiff reports can be auto-merged except a few.As it takes lot of time to go diff by diff in vimdiff and take the action.
I would like to know if there is an option available in vimdiff that automerges the differences in left and right files as long as there is no ambiguity and leaving the conflicted resolutions similar to the tools svn merge and cvs merge tools does?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
除非我们有一个基本副本,其中这两个文件分支并分别完成更改,否则不可能自动合并两个文件中的更改。如果某个item在一侧而另一侧没有,则无法判断该item是新添加的还是已存在的item被删除。由于合并存储库中的文件时存在基本副本,因此 cvs merge、svn merge 可以自动合并更改。
Its not possible to auto-merge the changes in two files unless we have a base copy where these two files branched and changes done separately. If an item is on one side and not on the other,it can't judge whether this item was newly added or an existing item was deleted. As there is a base copy exists while merging files in a repository, cvs merge,svn merge can auto-merge the changes.
如果您不使用版本控制,您可以尝试以下方式比较和修补:
diff file.orig file.txt >patch.txt
patch file2.txt patch.txt
更改将被合并,冲突的行将被放置在单独的文件中。
If you use no version control, you can try diff and patch this way:
diff file.orig file.txt >patch.txt
patch file2.txt patch.txt
Changes will be merged, conflicted rows will be placed in a separate file.
看起来 vimdiff 不允许这样做。手册页显示
“vimdiff - 使用 Vim 编辑文件的两个或三个版本并显示差异”
但是您可以查看 Kdiff3 可让您进行比较和合并。
Looks like vimdiff does not allow that. Man page says
"vimdiff - edit two or three versions of a file with Vim and show differences"
But you can have a look at Kdiff3 which lets you compare and merge.