UPDATED: Check out “git difftool” which makes this process much cleaner (than the commands I previously had listed here). Basically, you can tell git what to use as a diff tool and it’ll let you do things like:12Example 1: git difftool .htaccessExample 2: git difftool HEAD^^ robots.txt
Here is how I tell git to use vimdiff (these settings go in ~/.gitconfig):1234[diff]tool = vimdiff[difftool]prompt = false
Here are some helpful commands that will get you started with vimdiff.
- ctrl+w ctrl+w – switch windows
- do – diff obtain (grab from the other side)
- dp – diff put (move to the other side)
- [c – previous difference
- ]c – next difference
- :diffupdate – (updates the diff)
- :syntax off – syntax off
- zo – open folded text
- zc – close folded text
Lastly, I suggest using the peaksea colorscheme when using vimdiff. It makes it much easier to see the changes and work with them.