mcrwag
Last Updated: April 26, 2016
·
23.27K
· legumbre
5694116a1f44dd9f83c87466718bda9f

Use magit-ediff to resolve merge conflicts

Use magit-ediff or 'e' on an unmerged item to resolve merge conflicts with ediff. Magit will set up an ediff with three buffers A, B and C. A and B are the original (conflicting) files, and C is the conflicted merge.

Use 'n'/'p' to move to the next/previous conflict, use 'a'/'b' to choose which changes (those in a A or B) should be the ones to keep in the merged file.

You can always just switch to buffer C and edit what the merged version should look like.

Once you're done resolving all conflicts, just hit 'q' to exit the ediff merging session, ediff will prompt you to save the changes to the merged file. Save them and then move on to the next unmerged file.

Once you're done, just stage the resolved versions of the files and continue with your merge or rebase.

3 Responses
Add your response

5332
4bf98800fab22b23b184b1fe5574803d

Thanks for the info, it was useful!

Just for reference, I ran into a conflict when trying to merge a branch
into master. The Emacs frame where one has to type 'e' is the
one that contains the buffer magit: <thefilename>, not the
branch manager. The buffer where one has to type 'a' or 'b' is
the small one that pops up. And I had to stage and commit before
I could continue merging.

over 1 year ago ·
15431
C81642be8e39c756085eeceda6b16177

I use vim and a 'smart' alias https://coderwall.com/p/fc8edq . You could use fugitive.vim and call :Gdiff once its opened to get the same three way split, but I prefer the default file diff view git provides.

over 1 year ago ·
17814
None

Thanks for sharing. I really love it.

over 1 year ago ·