Custom Merge Tools Using GIT
IT has been my SCM tool of choice for white a number of years. Along with it, VIM has always been my intermediate editor for doing commit messages, viewing diffs and resolving merge conflicts. Recently, I have made the switch to Neovim as modern replacement for VIM. The nice thing with vim is that it came with a number of handy aliases, such as vimdiff
. Which was unfortunate, because I really liked VIM's diff support for GIT. I wanted to replicate that, but that would require some manual work on my part to get the two to play nice. Luckily, it isn't really that hard - turns out you can define any custom diff / merge tool for GIT. Here is what it looks like:
# ~/.gitconfig
[mergetool]
prompt = true
[merge]
tool = nvimdiff
[mergetool "nvimdiff"]
cmd = "nvim -d -u ~/.config/nvim/init.vim \"$LOCAL\" \"$MERGED\" \"$REMOTE\""
Thats it! when you need to resolve a merge conflict, you can simply specify nvimdiff
as the tool of choice
git mergetool --tool=nvimdiff
done.