I normally use git on the command line.
But when there is a merge conflict I use Vim to resolve them with (personally I do it with with the fugitive plugin). Note: fugitive is good for a lot of git manipulation from within Vim. My favorite feature is the 3 way diff of a merge conflict.
git supports this in vimdiff via git mergetool. I have installed fugitive but you can set it up manually (Thanks @Jay Thompson).
Manual Set up:
git config --global merge.tool vimdiff
git mergetool <file with conflicts>
The output is slightly different to what is described below (I have not personally used this). But the principle is the same but you have a fourth window at the bottom containing the result.
Set up with Fugitive
vim-fugitive is a git wrapper/integration plugin for Vim; it can do many things, and resolving conflicts is one of them.
<Install the Fugitive Plugin>
vim <file with conflicts>
- View 2 (left) : The code that was on your branch.
- View 1 (middle) : The merged code (with conflicts)
- View 3 (right) : The code that was merged into your code.
You can now pull and get text from the two other views into the central view (which is going to contain all the manual fixes). Once you have resolved all the conflicts manually simply exit vimdiff
Though you can use
:diffget <view number> and
:diffput <view number> to pull and push things between views. I don't personally find that very useful. All the code is already in the middle view. So I just like to edit that view manually until the conflict is resolved. Being able to see both versions of the code on either side of my editor window though is extremely useful.
Also a very good demo of its use here