I'm trying to use Magit with TRAMP. The remote host has multiple git versions, necessitating

(add-to-list 'tramp-remote-path "/usr/sup/bin")

in my .emacs. However, when I run magit-status in a TRAMP buffer, I get this error message in *Messages*:

magit-insert-head-branch-header: Wrong type argument: stringp, nil

And it is accompanied by this message in *Warnings*:

Error (magit): Magit requires Git >= 2.0.0, but on /ssh:nr@homework: the version is 1.8.3.

If multiple Git versions are installed on the host, then the
problem might be that TRAMP uses the wrong executable.

First check the value of `magit-git-executable'.  Its value is
used when running git locally as well as when running it on a
remote host.  The default value is "git", except on Windows
where an absolute path is used for performance reasons.

If the value already is just "git" but TRAMP never-the-less
doesn't use the correct executable, then consult the info node
`(tramp)Remote programs'.

Information about the context:

  • The value of magit-git-executable is "git".

  • The value of tramp-remote-path is ("/usr/sup/bin" tramp-default-remote-path "/bin" "/usr/bin" "/sbin" "/usr/sbin" "/usr/local/bin" "/usr/local/sbin" "/local/bin" "/local/freeware/bin" "/local/gnu/bin" "/usr/freeware/bin" "/usr/pkg/bin" "/usr/contrib/bin" "/opt/bin" "/opt/sbin" "/opt/local/bin").

  • On the remote host, there is a /usr/sup/bin/git with version 2.19.1.

My question: how I can figure out the absolute pathname of the git that Magit is running on the remote host?

Possibly relevant question: magit with tramp is not working with git correctly

  • Not an answer to your question, but it may give more information: M-x toggle-debug-on-error, try it again and look at the backtrace (or add it to the question).
    – NickD
    Commented Jan 23, 2019 at 0:02

1 Answer 1


If the value already is just "git" but TRAMP never-the-less doesn't use the correct executable, then consult the info node `(tramp)Remote programs'.

Did you do that? It says:

When remote search paths are changed, local TRAMP caches must be recomputed. To force TRAMP to recompute afresh, exit Emacs, remove the persistent file (*note Connection caching::), and restart Emacs.

And you would probably use:

6.6 Cleanup remote connections

TRAMP provides several ways to flush remote connections.

-- Command: tramp-cleanup-connection vec This command flushes all connection related objects. ‘vec’ is the internal representation of a remote connection. When called interactively, this command lists active remote connections in the minibuffer. Each connection is of the format ‘/method:user@host:’. Flushing remote connections also cleans the password cache (*note Password handling::), file cache, connection cache (*note Connection caching::), and connection buffers.

-- Command: tramp-cleanup-this-connection Flushes only the current buffer’s remote connection objects, the same as in ‘tramp-cleanup-connection’.

-- Command: tramp-cleanup-all-connections Flushes all active remote connection objects, the same as in ‘tramp-cleanup-connection’.

-- Command: tramp-cleanup-all-buffers Just as for ‘tramp-cleanup-all-connections’, all remote connections are cleaned up in addition to killing buffers related to that remote connection.

  • Consulted the info page, but missed the part about the cache. Problem solved! Thanks kindly. Commented Jan 26, 2019 at 15:41
  • With a local repository, (tramp-cleanup-all-connections) and (tramp-cleanup-all-buffers) were sufficient to convince magit to stop trying to connect remotely. Thanks for the time-saving pointers.
    – dat
    Commented Aug 31, 2020 at 21:39
  • Fyi, the pair of cleanup-all commands do save you from re-opening emacs and solved my identical issue, but the latter still closes all tramp-related buffers, which somewhat defeats the purpose of not simply restarting emacs in it's entirety.
    – Digicrat
    Commented Jan 13, 2022 at 22:29
  • Are you sure tramp-cleanup-all-connections wasn't sufficient on its own? (Also if you are using tramp-cleanup-all-buffers then per the documentation you wouldn't need to run tramp-cleanup-all-connections first.)
    – phils
    Commented Jan 13, 2022 at 23:53
  • 1
    tramp-cleanup-all-connections was not enough. Having buffers still triggers tramp-signal-hook-function: Tramp failed to connect. If this happens repeatedly, try ‘M-x tramp-cleanup-this-connection’ when running M-x magit, it went away after tramp-cleanup-all-buffers
    – phoxd
    Commented Apr 8, 2023 at 5:20

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.