:diffupdate - rescan the files for differences
]c - next difference
[c - previous difference
do - diff obtain (diffget)
dp - diff put (diffput)
zo - open folded text
zc - close folded text
The command git mergetool
is used to run one merge utility to resolve merge coflicts.
git mergetool [<file>...]
For each given
When we use vimdiff as a mergetool, the Vim windows are organized as following
+--------------------------+
| LOCAL | BASE | REMOTE |
+--------------------------+
| MERGED |
+--------------------------+
Where
Now, let's assume that you want to GET a change from the REMOTE version into the MERGED buffer. In the MERGED window, move the cursor to a conflict area and then type:
:diffget RE
This gets the corresponding change from REMOTE and puts it in the MERGED file. You can also type
:diffget BA " to get from the BASE buffer
:diffget LO " to get from the LOCAL buffer
There is also a command to PUT a change from a buffer to another. For example, if you want to PUT a change from the LOCAL buffer to the MERGED one; in the LOCAL window, move to a conflict area and then type
:diffput <MERGED-buffer-id or filename>
Fugitive Vim is a cool plugin that simplifies the Vim/Git integration for the most common operations.
A git conflict can be resolved by editing the file with vim and then start the diff tool with the command
:Gdiff " Gvdiff for vertically split windows
The Vim windows are organized is this way
+--------------------------+
| LOCAL | MERGED | REMOTE |
+--------------------------+
Where the meaning of the names are pretty obvious at this point.
The conflicts are resolved in the same way as above, that is using the Vim built-in command diffget
and gitput
.
Once we have finished with the merge, we can use the Gwrite
command to write the current file to the git index and exit from the vimdiff mode.
Fugitive-vim plugin can be downloaded here.
Proudly self-hosted on a cheap Raspberry Pi