How do I resolve a 3-way merge conflict in vim-fugitive by picking a specific version?
Answer
:diffget //2
Explanation
When resolving Git merge conflicts with vim-fugitive, running :Gvdiffsplit! opens a 3-way split: your current branch (left), the working file with conflict markers (center), and the incoming branch (right). You can resolve each conflict by pulling the version you want directly into the middle buffer using :diffget with a buffer specifier.
How it works
:Gvdiffsplit!— opens the 3-way diff with all three versions- The center buffer is the conflicted working file — this is where you make changes
//2refers to the ours buffer (your current branch / HEAD)//3refers to the theirs buffer (the incoming/merge branch)- From the center buffer,
:diffget //2pulls the change from your branch - From the center buffer,
:diffget //3pulls the change from the incoming branch - After resolving,
:Gwritemarks the file as resolved and stages it
Example
:Gvdiffsplit! " open 3-way split for the conflicted file
" Navigate to a conflict region in the center buffer
:diffget //2 " accept your version (ours)
" or
:diffget //3 " accept their version (theirs)
:Gwrite " save and stage the resolved file
Tips
- Use
]c/[cto jump between diff hunks across the three panes - In the left or right buffer,
:diffputpushes a hunk to the center buffer as an alternative workflow - The
//2and//3shorthand uses Vim'sfilename//bufnrbuffer naming — you can also use:lsto see actual buffer numbers and use those directly - After resolving all conflicts, run
:onlyto close the side buffers and return to a single window