When using magit on a local file, I stage my changes and I then press c and c again to commit. I get a new window showing the diff and a window for the commit message. I write my commit message press C-c C-c and the diff and commit window close.

However when using magit on a remote file using tramp, if I stage a change then press c and c again to commit, I only get a new window for the commit message not the diff window. I can write the commit message as normal, but not being able to see the diff at this point is annoying.

One thing I noticed is that if I do not stage my changes when using magit on tramp and I go to commit, I DO get a diff window, with the message in the message buffer "Nothing staged. Stage and commit all unstaged changes?(Y or n)" I can then then type Y to make the commit. But this way is only allowing me to see a diff for all changes to be placed in one commit, rather than the bits I want to stage for a commit.

How can I get magit to open the diff window when the commit message window is opened on a remote file using tramp?

  • If you hit C-c C-d (magit-diff-while-committing) in the COMMIT_EDITMSG buffer, does it bring up the diff?
    – npostavs
    Commented Apr 18, 2019 at 11:24
  • That does show the diff - thanks for that :) But it would still be good for that to come up automatically...
    – user27815
    Commented Apr 18, 2019 at 12:55

1 Answer 1


You can explicitly show the diff using C-d C-d in the COMMIT_EDITMSG buffer.

Normally the diff is automatically shown by magit-commit-diff, which is a member of server-switch-hook. That hook isn't run when committing over Tramp because in that case we cannot use the emacsclient to connect to the server (server.el) running inside Emacs. Instead an alternative implementation is used, which communicates on standard output/input. That doesn't call that hook.

  • 1
    for me it is C-c C-d and 'magit-diff-while-committing'
    – freeduck
    Commented Jun 9, 2020 at 8:06

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.