Going offline without your favourite Subversion repository?

Posted by Dr Nic on November 22, 2007 and blessed with 22 comments

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.

Git.

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:

Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. Steven Bristol Thu, 22 Nov 2007 07:07:15 UTC

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

  2. James Deville Thu, 22 Nov 2007 08:06:50 UTC

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

    JD

  3. halorgium Thu, 22 Nov 2007 09:34:54 UTC

    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. Offline SVN with GIT at Even Flow.. Thu, 22 Nov 2007 11:59:21 UTC

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

  5. Thu, 22 Nov 2007 12:51:59 UTC

    Cool! Thanks for nice information.

  6. Maritn Sadler Thu, 22 Nov 2007 13:05:37 UTC

    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 Thu, 22 Nov 2007 14:28:12 UTC

    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. Rodrigo Tassinari Thu, 22 Nov 2007 14:44:07 UTC

    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 Thu, 22 Nov 2007 14:49:20 UTC

    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 Fri, 23 Nov 2007 00:30:25 UTC

    @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 Fri, 23 Nov 2007 03:26:00 UTC

    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 Sun, 25 Nov 2007 12:02:27 UTC

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

  13. evilchelu Sun, 25 Nov 2007 22:31:24 UTC

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

  14. Joel Dietz Mon, 26 Nov 2007 14:13:50 UTC

    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 Mon, 26 Nov 2007 17:50:55 UTC

    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 Mon, 26 Nov 2007 21:09:20 UTC

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

  17. Dr Nic Mon, 26 Nov 2007 23:59:48 UTC

    @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. » links for 2007-11-23 | Paul Cowles Wed, 05 Dec 2007 22:17:04 UTC

    [...] 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 Fri, 28 Dec 2007 02:16:37 UTC

    I like “gitify” :)

  21. Getting Git at Excursus Sun, 30 Dec 2007 04:12:14 UTC

    [...] 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. Installing Git on my Mac « Grubby, but lustrous Tue, 08 Jan 2008 02:19:13 UTC

    [...] 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 [...]

Comments