After last update, the *magit-refs buffer no longer switches to the branch under point when pressing RET, instead, it shows last commit from the branch I wanted to check out (completely useless behavior, at least for me). Is there any way to have RET work as it used to?

I figured I could do bbRET, to achieve the same effect, but I'm too used to RET working as it used to, and when accidentally I press it, Emacs hangs because the diff may be quite large.

1 Answer 1


As highlighted in the release notes for version 2.9 (which explains at some length why this change was made):

Please note that you can trivially revert this change locally, by adding (setq magit-visit-ref-behavior '(checkout-any focus-on-ref)) to your init file.

If you're reverting to that behaviour, you may appreciate this safety-net for preventing accidental check-outs:

;; I keep unintentionally checking out branches from the refs buffer.
(defadvice magit-visit-ref (around my-protect-accidental-checkout)
  "Protect against expensive accidental checkout of a reference."
  (if (derived-mode-p 'magit-refs-mode)
      (if (y-or-n-p "Checkout reference? ")
        (message "Aborted."))
(ad-activate 'magit-visit-ref)
  • 1
    It's one of those imaginary "UX improvements"... I see not only in Magit, unfortunately... sigh. Have been using Magit for at least five years now, and not even once checked a branch I didn't intend to check.
    – wvxvw
    Jan 17, 2017 at 7:21
  • 3
    I lost count of the number of times I did it before I wrote that particular advice -- and every single time was super-annoying. It's not an "imaginary" improvement; it's merely an example of the fact that Magit caters to a wide range of users, with a similarly wide range of habits and expectations, and it's impossible to please everyone (but I think tarsius does a fantastic job of pleasing as many people as possible, by implementing backwards-compatibility features like this one when changes are made).
    – phils
    Jan 17, 2017 at 7:41
  • Erm... no. Branch checkout is an asynchronous operation: you have all the tools you need to cancel it, if you think it's a wrong branch. Generating a diff isn't, so you are stuck until it ends.
    – wvxvw
    Jan 17, 2017 at 11:43
  • 1
    I can only disagree about the relative severity of the two unintended actions (and I'm pretty sure you can C-g out of a magit diff generation) -- but I wasn't trying to argue that point, and really I feel it's probably just another example of differing use-cases.
    – phils
    Jan 17, 2017 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.