0

How can I use a remote git executable for all git operations when accessing a file via SSHFS?

I mount a remote system's git repo via SSHFS on my local computer. The git repo is medium-sized with about 1000 files and a few years of history. My local git executable it is unusably slow for all operations on SSHFS.

Time for git status:

  • Executing git from the Remote system: 0.012s total
  • Local git on SSHFS: More than 2 minutes.

Constraints:

  1. I'm not allowed to store source code on my laptop due to corporate policy so a normal push/pull git workflow isn't allowed.
  2. I'd prefer to keep git functionality enabled over SSHFS rather than disabling git on SSHFS and performing git operations on the remote machine.
  3. There's a number of Emacs tools that use git including magit, git-gutter, git-gutter+.
2
  • 1
    Lkkely not what you intend, but have you tried to access your files via Tramp? magit would work then out-of-the-box on the remote machine, AFAIK. Commented Oct 30, 2016 at 7:19
  • I've had trouble getting tramp to work properly. I'll should probably explore that route before I start writing hacky code to tweak how emacs invokes executables.
    – Joe
    Commented Oct 31, 2016 at 5:11

2 Answers 2

2

The advantage of using sshfs is that you can remote files using local processes just as if the files actually were local. Except it's significantly slower than if the files actually were local when doing IO-heavy stuff. The advantage then becomes a disadvantage.

It wouldn't make much sense to teach Magit to run Git on the other machine. That would be an immense effort and the only effect would be that the advantage and the disadvantage of using sshfs cancel each other out.

Instead you should figure out how to address the issue you are having with Tramp. That's the right tool for the job. Or ssh to the remote machine and then run emacs -nw (if available).

1

See tarsius' response for an approach with tramp. That said, this is doable from outside Emacs via the very helpful https://github.com/ericpruitt/sshfsexec. Basically, you sym-link file intensive commands (like git) to sshfsexec.py which in intelligently forwards commands via ssh if you're in a SSHFS.

The benefits of this approach are:

  • You can use a GUI Emacs.
  • You still have the sshfs.

If you're on a Mac, you'll need to edit the sshfsexec.py to replace sshfsmountmap with hardcoded values due to https://github.com/ericpruitt/sshfsexec/issues/2

def sshfsmountmap():
    """
    Return a dictionary mapping mount points to tuples containing the
    remote login ([user@]hostname) and remote path for all remote hosts
    mounted with sshfs.
    """
    # /proc/self/mountinfo isn't available on mac, so hard code values.  See
    # https://github.com/ericpruitt/sshfsexec/issues/2
    SSH_ADDRESS = '[email protected]'
    # List of paths is available in remount.
    return {
        '/home/joe': (SSH_ADDRESS, '/remote/path'),
        '/home/build': (SSH_ADDRESS, '/remote/build'),
    }

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.