Git vimdiff Mergetool Cheat sheet

Your project is going absolutely great. You’re committing regularly and you’re getting close to the release date and then you that the is a (CONFLICT).

You see something like : file.extension : needs merge ,?
Then you google ans see that opening a merg tool will help and then suddenly you’re dumbstruck and you can’t even move.

The first thing I wanted to do was to the heck out of there.

Press “ESC” then press ” : ” after that enter ” qall! ” , after this make sure to selecet no when you’re prompted with “Was the merge successful? [y/n]” . Unless you’ve fixed it select no.

Secondly, what’s up the 4 windows? Please not the descriptions below are not in order 1,3,2,4:

1. The target branch, which is the one you’re on now. This is where you would like to merg the other branch into, but this window is only used as a reference to see what the current branch looks like.

3. The remote/merge branch which is the branch that you would like to merge into the local/target branch above (1).

2. The most common ancestor of the target (1) and the merge(3) branch.

4. The final branch into which you would like to merge the target and the merg branch. This a computer generated file into which the most common items is merged but this is where you need to pull items from target (1) and merge(3) into, to give you the final file.

Now the first thing you should note about the four windows is that you can have the cursor in any one of the four and work from there. To move the cursor around you press:

‘CTRL + W’  ‘ CTRL + W’    (press it twice)

The second thing you would like to do is move from one conflict area to the next.

‘]c’  (right square bracket ‘c’) move you to the next conflicting text

‘[c’   (left square bracket ‘c’) moves you to the previos conflicting text.

:ls identify the windows (names and numbers) This is important so you can combine it with diffput and diffget commands below.

:diffget  *     diff get takes a change and brings it into the current working window. It is important for you to use this with the identity that you find when  running :ls . You can also use ‘do’ as a shortened version (without the colon)

:diffput modify another buffer from the current focus area.

I’ll add more and change this cheat sheet as I discover this tool.

Published by

Dwain Maralack

Servant, Husband, Software Engineer and all round fun-loving guy, I work as a Developer at WooThemes.

Leave a Reply