Conflicted is a Vim plugin that aids in resolving git merge and rebase conflicts. It relies on tpope's fugitive plugin to do the heavy lifting and provides a few wrapper commands and a streamlined workflow to make resolving conflicts much more straightforward.
The easist way to use Conflicted from git is to add an alias for it that opens vim with the conflicted plugin activated. You can add the alias with the following shell command:
git config --global alias.conflicted '!vim +Conflicted'
From there, you can run conflicted directly from git with:
Which will open Vim and start up the plugin.
Conflicted provides three primary commands for working with conflicts:
Conflicted will add all the conflicted files to Vim's
arglist and open
the first in
After editing the merged file to resolve the conflict and remove all conflict
GitNextConflict will mark the file as resolved and open
the next file in
Merger mode for resolution.
If you are on the last file,
GitNextConflict will quit Vim.
Merger will open the various views of the conflicted file. This command is
exposed for completeness, but likely you will not need to call this command
directly as both
GitNextConflict will call it for you.
Conflicted provides mappings to perform a
diffget from the working version
of the file, pulling from either the upstream or local version. These mappings
are provided in both normal and visual mode:
dgu- diffget from the upstream version
dgl- diffget from the local version
If you would prefer different mappings, you can overide with the following in your vimrc:
" Use `gl` and `gu` rather than the default conflicted diffget mappings let g:diffget_local_map = 'gl' let g:diffget_upstream_map = 'gu'
Conflicted will configure the tab label to display the name of the revision in
the tab. This is done via the
tabline setting in terminal Vim, and the
guitablabel setting in graphical Vim, ie MacVim.
Add the following to your vimrc to display the version name of each split in the vim statusbar:
Normally it will not add anything to the statusline, but if you are in conflicted mode then it will add the conflicted version, ie 'local', 'working', etc.
If you don't have a preferred installation method, I recommend using Vundle. Assuming you have Vundle installed and configured, the following steps will install the plugin:
Add the following line to your
~/.vimrc and then run
" Fugitive is required for Conflicted Bundle 'tpope/vim-fugitive' Bundle 'christoomey/vim-conflicted'
Conflicted makes reference to four different versions of each conflicted file. These versions are:
base- The common ancestor of the file in the upstream and local branches
upstream- The core branch (usually
master), that you are merging into or rebasing onto.
local- The feature branch containing your changes
working- The final combined version of the file
For each conflicted file, Conflicted will open 3 tabs, each with a different diff view presented:
- Gdiff 3-way - 3 way diff comparing the upstream, working, and local versions of the file.
- Upstream Changes - A 2 way diff between the base and upstream versions of the file.
- Local Changes - A 2 way diff between the base and local versions of the file.