使用vimdiff作为git mergetool

设置 git mergetool 为 vimdiff

git config --global merge.tool vimdiff
git config --global merge.conflictstyle diff3
git config --global mergetool.prompt false

用vimdiff解决合并冲突

运行git mergetool,vim将展示如下

+--------------------------------+
| LOCAL  |     BASE     | REMOTE |
+--------------------------------+
|             MERGED             |
+--------------------------------+

 vimdiff 随笔

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。

移动光标到不同的split

Ctrl w + h   # move to the split on the left 
Ctrl w + j   # move to the split below
Ctrl w + k   # move to the split on top
Ctrl w + l   # move to the split on the right

移动到MERGED文件上(Ctrl + w, j),移动光标到一个合并冲突的区域([c]c),然后:

:diffg RE  " get from REMOTE
:diffg BA  " get from BASE
:diffg LO  " get from LOCAL

最后使用:wqa保存更改并关闭所有的分割

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄