When I met a conflict, I tried to use git-mergetool
to solve it. I typed:
>git mergetool -t vimdiff
It opened vimdiff
After lots of research for issuing mergetool with vimdiff and only 3 windows, I came up with this configuration, that allows me to chose when I want 3 windows or the default 4 windows:
git config --global merge.tool vimdiff
git config --global alias.mt mergetool
git config --global mergetool.merge3.cmd 'vim -d -c "wincmd l" "$LOCAL" "$MERGED" "$REMOTE"'
git config --global alias.m3 'mergetool -t merge3'
Now you can start 3 windows just typing:
git m3
And the default (4 windows) will still works as expected with:
git mt
Also, you probably would like to add this lines to the end of your ~/.vimrc
or /etc/vim/vimrc
" shortcuts to vimdiff
let mapleader=','
let g:mapleader=','
if &diff
map 1 :diffget LOCAL
map 2 :diffget BASE
map 3 :diffget REMOTE
endif
This will create shortcuts like ,1
to grab from left, ,3
to grab from right (in both modes) and also ,2
to grab from base (center window) in the 4 windows mode.
That helps a lot!
My ~/.gitconfig
file looks like this:
[user]
name = Dr Beco
email = my@email
[merge]
tool = vimdiff
[mergetool "merge3"]
cmd = vim -d -c \"wincmd l\" \"$LOCAL\" \"$MERGED\" \"$REMOTE\"
[alias]
lo = log --pretty=format:\"%h %ce %cd %s\" --graph
co = checkout
ci = commit
cm = commit -a -m
st = status
br = branch
m3 = mergetool -t merge3
mt = mergetool
[diff]
tool = vimdiff
I hope this helps you (and those who get to here).