This Time Self-Hosted
dark mode light mode Search

How to use GIT via SFTP only

GIT is pretty nice for an SCM software, it’s nice to be able to work locally on a project without losing track of the changes before publishing it on a proper server. One problem of it, though, is that you can’t find much hosting space for it, as it requires you either HTTP push capabilities or an SSH access where GIT is installed, as it needs it server side to be able to push.

I’ve worked around this for most of my projects by hosting my own GIT repositories on Farragut, but this limits quite a bit the scope of the projects, and limits also the fact that if I’m offline, my repositories are, too. For this I’ve moved my overlay to overlays.gentoo.org as soon as GIT support was added.

When I started doing some serious work on Rust and Ruby-Hunspell, I decided I couldn’t just leave them to die with my server if my connection is revoked, or if something happens to it, so I’ve looked for an alternative solution. I had already hosting on RubyForge for the ruby-hunspell site but the only access to the site was through SFTP, and thus git wasn’t able to handle it.

Thinking of it, I found a solution that was quite obvious: GIT can push to a local path too, so I just needed to get a copy of the pushed repository and load it there; using SFTP would have been slow, but worked. I first did it that way, but it grew tired easily.

The next step was helped by Timothy, who talked often of Fuse and who handled together with genstef the ebuilds for fuse to run on Gentoo/FreeBSD: using sshfs and fuse, I could push to a «local» path that was instead mounted from the RubyForge SFTP site. And that’s what I’m using now to push both ruby-hunspell and rust repositories, both of which are available to users via HTTP on the two respective sites.

I found one big showstopper with this approach today, but after wasting some of Ferdy’s time, I found a pretty simple workaround for it too: during the second push, GIT tries to rename the master.lock file into master, without removing master of course; on SSHFS this does not work by default and returns an EPERM error (Permission denied); to fix that you just need to enable the rename workaround while mounting the SFTP directory.

It is slow, but it works nicely if you don’t have a server where you can use GIT properly.

For who’s wondering, this is what I’m using currently to mount the RubyForge server:

sshfs -o workaround=rename rubyforge.org:/var/www/gforge-projects/ 
    /media/repos/flame/remote/rubyforge

I hope this post can be useful to someone else too 🙂

Update (2017-04-22): as you may know, Rubyforge was shut down in 2014. Unfortunately that means that most of the Rust documentation and repository are probably gone (I may have backups but I have not uploaded them anywhere).

Comments 2
  1. Hi Diego!Your approach is certainly interesting and a good solution if one has already chosen a hosting provider. If one starts a new project, there is “Free Public Git Hosting”:http://repo.or.cz/ available (as long as the project is free software and its repository size stays below 100 megs).RegardsChristian

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.