When I met a conflict, I tried to use git-mergetool
to solve it. I typed:
>git mergetool -t vimdiff
It opened vimdiff
Note: while you can use only 3 Windows as described in Dr Beco's answer
(vim -d -c "wincmd l" "$LOCAL" "$MERGED" "$REMOTE"'
),
the 4-windows mode is enhanced with git 2.8 (March 2016)
See commit 2300328 (29 Jan 2016) by Dickson Wong (diwo).
(Merged by Junio C Hamano -- gitster -- in commit 82c17b7, 17 Feb 2016)
The
vimdiff
backend for "git mergetool
" has been tweaked to arrange and number buffers in the order that would match the expectation of majority of people who read left to right, then top down and assign buffers 1 2 3 4 "mentally" to local base remote merge windows based on that order.
Internally, git will now use:
"$merge_tool_path" -f -d -c '4wincmd w | wincmd J' \
"$LOCAL" "$BASE" "$REMOTE" "$MERGED"
instead of:
"$merge_tool_path" -f -d -c 'wincmd J' \
"$MERGED" "$LOCAL" "$BASE" "$REMOTE"
mergetool
: reorder vim/gvim buffers in three-way diffsWhen invoking default (g)
vimdiff
three-way merge, the merged file is loaded as the first buffer but moved to the bottom as the fourth window.
This causes a disconnect betweenvim
commands that operate on window positions (e.g. CTRL-W_w) and those that operate on buffer index (e.g. do/dp).This change reorders the buffers to have the same index as windows while keeping the cursor default to the merged result as the bottom window.