Home > SIParCS 2009, Tech > Git over SSHFS

Git over SSHFS

While working at NCAR, I stumbled into a situation where I needed to use Git over an sshfs mounted directory.  After beating on git and looking at its source code and not making much progress, I finally found a very simple solution related to how I mount the sshfs directory.

I’ve been working on a codebase at NCAR for my summer SiParCS internship that is based in an Subversion repository.  However, the code I have is unreleased and I haven’t been given commit access to the repo.  Also, I hate the feeling of working on code that isn’t properly versioned as I’ve lost work one too many times and never want that to happen again.

While working, I found myself needing multiple versions of some code I was working on (where each version was gathering different sets of data).  Rather than commenting in/out various sections of the code, git branches would work perfectly in this situation.

Keep in mind that the code I’m working on resides on an AIX front-end node to a reasonably powerful supercomputer.  The tool support on this machine is lacking, I have no zsh, updated vim, git, etc.  To get around this tool deficiency, I mount the code I’m working on locally on my machine using sshfs.  This works great!  However…  I still have no version control, so I decide to attempt to add the code to a git repository.

I started by removing the .svn directories using one of my favorite shell aliases, svnnuke.  I then created a git repo with git init.  So far so good.  Finally, I attempted to add all of the files to the repo for the initial commit with git add ..  However, this produced the error: 'fatal: Unable to write new index file'.  After searching through the git source for the location of the error string and trying many variations of various git commands, I was stuck.

This morning I approached the problem again, from a different angle.  I realized the problem was most likely not with git, but with the fact that I’m working over sshfs.  Therefore, I may solve the problem with how I am mounting the remote filesystem.  I googled for ‘git sshfs’ and found an article discussing Bazaar and SSHFS.  This article containted the solution to my problem: mount the remote filesystem using sshfs with the -oworkaround=rename option.  Poof!  Git is suddenly working and I’m hacking on the code versioned under git and all its glory!

  1. Andrew
    February 24th, 2010 at 16:21 | #1

    I ran into a similar problem. My remote machine lacks many of the useful tools on my local development machine, namely vim and git.

    However I have the added problem of working on a shared server and am limited to a user account that is not in the sudoers file. Since the account that I develop with on my machine is not the same as my account on the remote server, git was failing with a “could not commit config file” error.

    So, on my local machine, I created a user and group to mimic the user and group on the remote machine. (Notice that I am already root. If you don’t like to roll as root, you’ll have to use sudo).

    root@bitbox: addgroup –gid=1235 studmuffins
    root@bitbox: adduser andrew –uid=1234 –ingroup studmuffins

    Then, I had to add a couple more options to the sshfs command in addition to the workaround:

    root@bitbox: sshfs -o workaround=rename -o allow_other -o uid=1234 -o gid=1235 andrew@shittyhost.com:/path/to/remote/dir /path/to/local/mountpoint

    So far, this seems to be working. But a WARNING to everybody using git over sshfs is very, veeeeery, sloooooooooooooooooowwwwwwww. For instance, I tried doing:

    git add *

    It took about 30 minutes for a 60MB project, only to fail entirely due to permission issues on a single file. Suck.

    • February 26th, 2010 at 10:47 | #2

      Ouch, sounds like even more of a restricted setup than I had. Thanks for the additional tips. Yes, I did notice that git over sshfs was a bit slower. However, I didn’t have ~50mb projects, so I probably didn’t see as much of an impact as you did.

  2. Mark
    December 16th, 2010 at 16:00 | #3

    Thanks for publishing this tip! Just saved me a lot of time and frustration…

  3. Yann Droneaud
    February 21st, 2011 at 02:47 | #4
  4. December 20th, 2011 at 03:33 | #5

    Me = happy camper :)

    Nice tip.

  5. Rui Abreu
    December 29th, 2011 at 13:27 | #6

    Thank you !

  1. No trackbacks yet.