I am debugging a very slow performance of git commands over SSH, including via packages such as VC and Magit.

Even using VC on emacs -Q is extremely slow.

I get

Tramp: Opening connection git for <<hostname>> using ssh

over and over, when I would expect TRAMP to reuse the first connection.

What is strange is that this behavior seems to be confined to git commands: if I open eshell and run ls, TRAMP opens a new connection only once (and the following commands runs quite fast). In this case, the output is (attention to nil instead of git):

Tramp: Opening connection nil for <<hostname>> using ssh

Conversely, if I do git status, every time the command is run, a new connection is opened, with the text mentioned above.

Would someone know how to make TRAMP reuse the connection even for git commands?

  • eshell implements its own ls command in elisp, so I think that's not a good comparison. which ls => "eshell/ls is a byte-compiled Lisp function in ‘em-ls.el’."
    – phils
    Commented Mar 9 at 1:31
  • Maybe research/check your ControlMaster config for ssh. That's the "normal" approach I'm familiar with for getting ssh to re-use its connections. For a while now Tramp has tried to make use of that by default, but it may depend on which Tramp method you're using, and/or how ssh is configured on your system.
    – phils
    Commented Mar 9 at 1:36

1 Answer 1


In vc, vc-git-command is called, which uses vc-do-command. This uses an asynchronous process via start-file-process, and so does Tramp: opening a new process for a given git command.

I haven't checked for magit, but something similar might happen.

You might try to improve the performance by using direct async processes in Tramp (see its manual).

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.