Merging with smerge

I don't often have occasion to resolve git merge conflicts so I never remember the details and end up changing things by hand. This tweet

caught my attention so I followed the link and read about smerge. It's a lighter weight solution than ediff and thus easier to use. I hardly ever use ediff so I always have to figure things out when I do. That's not really what you want to be doing in the middle of resolving a merge conflict so smerge is perfect for me because there's not much to remember. All you have to do is press Return while the point is on an unresolved file and you enter smerge-mode.

I really should take the time to get proficient with ediff but until I do, smerge is an easy way to resolve conflicts without invoking the heavy machinery of ediff.

This entry was posted in General and tagged , . Bookmark the permalink.
    • jcs

      Looks pretty nice. If you get a chance, why don't you write up a post on how you integrate it into your (Magit) workflow.

  • Yang Zhao (赵扬)

    I have this hydra for smerge, which I do not use often and always forget the key bindings:

    (defhydra hydra-smerge
    (:color red :hint nil
    :pre (smerge-mode 1))
    "
    ^Move^ ^Keep^ ^Diff^ ^Pair^
    ------------------------------------------------------
    _n_ext _b_ase _R_efine __: base-other
    ^ ^ _a_ll _r_esolve
    _q_uit _RET_: current
    "
    ("RET" smerge-keep-current)
    ("C" smerge-combine-with-next)
    ("E" smerge-ediff)
    ("R" smerge-refine)
    ("a" smerge-keep-all)
    ("b" smerge-keep-base)
    ("m" smerge-keep-mine)
    ("n" smerge-next)
    ("o" smerge-keep-other)
    ("p" smerge-prev)
    ("r" smerge-resolve)
    ("" smerge-diff-base-other)
    ("q" nil :color blue))

    • jcs

      I really like this. If you don't resolve merge conflicts everyday it's very easy to forget the key bindings. This hydra really helps with that.

  • Skywalker

    There is also `vc-resolve-conflict` (iirc), it's built on top of `ediff` (again iirc) but there's not much to figure out: n/p for next/previous conflict, a for the left version of current conflict, b for the right version.

    And at the end it automatically does the right thing to mark the conflict resolved for the vc.

  • Phil

    I really should take the time to get proficient with ediff

    I can only recommend doing that. Ediff is entirely excellent, and it's a boon having that inside Emacs. The basics are really easy to learn, and you can type ? to toggle the command buffer's help at any time. I greatly prefer (setq ediff-split-window-function 'split-window-horizontally) and (setq ediff-window-setup-function 'ediff-setup-windows-plain) to the defaults for those, but YMMV. Browse the Customize group ediff.

    • jcs

      OK, you've guilted me into it. That and the fact that every time I've followed your advice I've been really glad I did.

      • zerOnepal

        scrolling via your posts after reading http://irreal.org/blog/?p=5651
        a little bit of surprise getting featured in your post,
        Can't stop comment here... :)

        looking forward to learn ediff, i just need yet another merge conflict :D

        • rhoitman

          just create one @thapakazi:disqus :D

          • thapakazi

            forgot to reply, learning ediff is more awesome... Now I am like:

            hey merge conflict, yes you... i dare you visit me more often, i fear you no more. heehe