You might want to try out
smerge-mode just open the conflicted file and do M-x
smerge-modeRET. It will highlight all the conflicted regions. It also adds keybindings to easily resolve the conflicts, consult its documenation C-hf
smerge-modeRET to know them.
I find the default prefix for
smerge-mode C-c^ cumbersome so I have changed it to C-cv
(setq smerge-command-prefix "\C-cv")
For me the most important bindings are:
smerge-next bound to smerge-command-prefixn to move to next conflict.
smerge-previous bound to smerge-command-prefixp to move to previous conflict.
smerge-keep-current bound to smerge-command-prefixRET to keep the version the cursor is on.
smerge-keep-mine bound to smerge-command-prefixm to keep your changes.
smerge-keep-other bound to smerge-command-prefixo to keep other changes.
smerge-ediff bound to smerge-command-prefixE to start an ediff session to merge the conflicts. This is same as
vc-resolve-conflicts (thanks @phils and @Malabarba for pointing this out).
Enabling smerge-mode automatically
UPDATE: The following is relevant only on Emacs versions before
25.1, the following can cause problems on later versions, see https://github.com/magit/magit/issues/3897
Additionally you might be interested in automatically enabling
smerge-mode when visiting a file/buffer with conflict markers you can use something like the following to achieve this
(defun my-enable-smerge-maybe ()
(when (and buffer-file-name (vc-backend buffer-file-name))
(when (re-search-forward "^<<<<<<< " nil t)
(add-hook 'buffer-list-update-hook #'my-enable-smerge-maybe)
Note that I am using
buffer-list-update-hook and not
find-file-hook since most of the times I get conflicts in a buffer which is already open in emacs in which case
find-file-hook is of no help.
Also check other methods mentioned in this answer