By default if you use fugitive.vim's :Gdiff
on a file buffer which is in conflict with git, you will get a three way diff showing HEAD
, the working copy (with conflict markers), and the merge
.
I like to have git config merge.conflictstyle diff3
set, which includes the base (most recent common ancestor of HEAD
and merge
in the conflict markers.
Unfortunately even with diff3
as the conflictstyle
in fugitive.vim you still only get 3 panes (no base).
Does anyone know how to make show it in another pane? Ideally about the working copy.
This comment from Tim Pope seems to provide some clue, but I can't quite figure it out.
You can do it with the following steps:
:split
- Do a horizontal split:Gdiff
- Diff in the top windowGedit :1
- Load ancestor in bottom windowGedit :2
loads head and Gedit :3
loads the merge
The quickest way I know of is this command, issued in the conflicted buffer:
:Gsdiff :1 | Gvdiff
You must enter these commands as a one-liner, the effect is different when you enter them as two separate commands.
The result looks like this:
+---------------------------------------+
| common ancestor (:1) |
+-----------+--------------+------------+
| | | |
| HEAD (:2) | working copy | merge (:3) |
| | | |
+-----------+--------------+------------+
The stuff inside the brackets are the 'revision' specifiers that fugitive.vim understands in this context. See :h fugitive-revision
for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With