Dr Nic

Going offline without your favourite Subversion repository?

UPDATE: useful gitify command below.

All my client projects are hosted on Subversion repos. All my OSS projects are hosted on Rubyforge Subversion repos.

And tomorrow I head off for the 2nd “no internet” RailsCamp megafest, being held outside of Melbourne. From what I heard about the 1st one, it involved a lot of Guitar Hero II and beer. This weekend I’m promised that someone is bringing a Wii – dear God I do love the tennis game.

Like MacDonalds burgers and Veganism, if there are two things that don’t go together its Subversion and “No Internet”.

Fortunately, for all RailsCampers, there is a solution to your fears that you won’t be able to hack on your favourite project, and will be forced into playing Guitar Hero II/III and/or the Wii for the whole weekend.


Specifically, the git-svn command.

More specifically, follow the following steps:

  1. git-svn clone <your svn url> projectname.git
  2. Go camping for the weekend.
  3. Commit changes with git commit -a -m "hahaha I'm camping and working - doh!"
  4. Come home from camping.
  5. git-svn rebase to re-import any SVN changes that might have been committed whilst you were away. If there are conflicts, just follow the instructions.
  6. git-svn dcommit and your svn repository will be updated with all your fancy changes; no one will ever know you used Git.

Installing Git

I remember having problems getting git-svn to run because the default path to the perl cmd is crap, and you need to specify PERL_PATH='/usr/bin/env perl', I think, before installation.

For MacPorts etc, its sudo port install git-core. I think the reason its not just called ‘git’ is to remind you that you know nothing about git. Which is fair. You don’t if you don’t know how to install it, I guess.

From source, get the tarball from the home page.

For Windows, use cygwin.

Gitify command

Want a utility cmd to create a Git repo in the parent folder of a Subversion project? That is, go to your Rails app that is checked out from a Subversion repo, and run gitify, and you will have a foldername.git folder in the parent folder.

Stick this code into ~/bin/gitify and add ~/bin to your path:

22 Responses to “Going offline without your favourite Subversion repository?”

  1. Nice one Dr. Nic. I’ll have to check it out.

  2. I think you need to do a sudo port install git-core +svn to get git-svn in addition to git.


  3. halorgium says:

    The PERL_PATH fix is needed for building git from source manually I think.
    Also, more info is available at http://utsl.gen.nz/talks/git-svn/intro.html

  4. [...] More info can be found here. Published at November 22, 2007 in Uncategorized. [...]

  5. ì²­ says:

    Cool! Thanks for nice information.

  6. Good tip.

    I’m currently using SVK which essentially does the same job. I have looked into Git before but I was put off after hearing quite a few tales of folk losing work with git-svn. Perhaps things have changed now?

  7. AkitaOnRails says:

    Great! I’ve been evangelizing Git recently as well. It’s merging features surpasses all others. Rubinius and other projects as starting to use Git as well so this is a good proposition.

  8. Great tip! One question though, when you run “git-svn dcommit”, all the commits done via git will be transffered to subversion all at once or they will be “replayed” one at a time?

  9. luislavena says:

    I use Bazaar for that, mirror the trunk of my projects on a shared repository and create branches for every thing that need separate work (or just use the shelve to store changes) :-)

  10. Dr Nic says:

    @Rodrigo Tassinari [via] – they’ll be replayed one at a time and look as if you committed when you did. of course if there are conflicts you’ll be asked to resolve them for each checkin you’ve previously done.

  11. Dr Nic says:

    Gitifying rails takes hours. Fortunately Steve Purcell has got a git clone already online.

    git clone git://git.sanityinc.com/rails.git rails.git

    This takes just a few minutes.

  12. jacobat says:

    Is there some way to make git pickup empty directories? Like the log directory?

  13. evilchelu says:

    Jacobat: one way to do that is to add a .gitignore file containing * in the log directory

  14. Joel Dietz says:

    I get the following w/ macport:

    Error: Target org.macports.activate returned: Image error: /opt/local/lib/perl5/5.8.8/darwin-2level/perllocal.pod already exists and does not belong to a registered port. Unable to activate port git-core.
    Error: Status 1 encountered during processing.

  15. Phil says:

    I think the package is called git-core to distinguish it from the GNU Interactive Tools. That’s what they tell us over in .deb land, at least. (And you get a warning when you install GNU Interactive Tools that it’s not the DVCS, and wouldn’t you perhaps like to install this other similarly named package, and have a nice day.)

  16. Craig Buchek says:

    Shouldn’t you do a git-svn fetch or git-svn rebase before the git-svn dcommit?

  17. Dr Nic says:

    @Craig Buchek [via] – yep you should if there is any chance someone else has modified the repo. I’ve updated the step-by-step instructions, thx.

  18. [...] Dr Nic » Going offline without your favourite Subversion repository? going offline with svn (tags: svn) [...]

  19. [...] this is worth looking at if you want to play around with code without committing to a central [...]

  20. Garry says:

    I like “gitify” :)

  21. [...] allows you to use Git locally with a centralized subversion repository. Dr Nic explains how in this post. I will be exploring this in the New Year. So I have installed Git. Here is the bash script that I [...]

  22. [...] Git on my Mac Inspired by Dr Nic’s post I wanted to install git on my Intel-based Mac. Why? There were two motivations – I frequently do [...]