On Git
If you’re a developer, and read other developers’ blogs, odds are you’ve heard of git. While some of the posts about git are almost absurdly exuberant, there’s no denying that it fixes some of the really hard problems with source control.
I’ve been using git-svn as a frontend for my rails development for around 4-5 months, I can’t imagine going without fast local branches, smart merges and rebases. So naturally I’m interested in migrating rails from subversion to git, as are the rest of the core team. Unfortunately it’s not as simple as running git-svnimport and updating some webpages. We rely on several pieces of subversion which aren’t quite so easy to replace.
Our scripts work with Subversion
Our subversion servers do a lot of traffic. The rake rails:freeze:edge task contributes to this, but so do people using svn:externals for their rails application. The amount of traffic the servers do is an indication that people like to use this functionality and we shouldn’t just turn it off one day. The svn command line client is extremely portable and available on almost every system. The git tool set doesn’t have the equivalent of an ‘svn export’, which is what the freeze tasks and plugin installers rely on.
Trac works better with svn than git
The ability to automatically close tickets with a commit message is really useful, as is the automatic hyperlinking that we can use in ticket comments. There are hacks to add git support to trac, but it will take some time to evaluate them. This stuff currently ‘just works’ with subversion.
Interim solution
In the meantime, I’m publishing my git-svn powered repository locally, at github and gitorious. If you want to use git to work on your rails patches, feel free to grab me in #rails-contrib to talk about your branches, and the steps to get them merged.
Unfortunately due to the way git-svn works, when your patches get applied to rails they’ll be squash merged and then rebased out of existence by git-svn. So once your branch gets accepted, you’ll have to throw it away or suffer thousands of merge conflicts. To minimise your pain make sure you have one branch per feature and ensure all branches can exist independently.
While the limitations of git-svn mean we’re only testing a subset of the git workflow, it’s important that we figure out kinks in a git workflow for rails, so please help out.
Migration plan
So in order for us to migrate from subversion to git, we need:
- A reliable read-only svn mirror based on our git repository
- A git post-commit hook which allows us to close tickets
- Something similar to our trac browser + ticket integration.
The post commit hook and browser aren’t particularly difficult, while gitweb is a little ugly, I’m sure we could make something work. The real challenge is the backwards compatible, read-only svn mirror. Evan had a post on this a while back but that involves initializing a brand new repository and apparently is prone to breaking from time to time. Rick has a simple file copying solution which we may end up using.
If you have ideas or experience with any of these issues, and the motivation to help out, please let us know by emailing the rails-core list or grabbing me in IRC.


Cristi Balan February 24th, 2008 @ 04:22 AM
If you want to track local changes, you can’t do that with git submodules without having a bunch of other repositories.
So, I wrote braid to be used instead of svn:externals or freezing rails. I’m using it to track rails and a bunch of plugins in my repository and it gets the job done.
You can grab it from github.
There is one problem, but it should be fixed soon: for now, only the person that adds the remotes in the repository can update them (because they’re only stored locally). But, with the metadata braid stores it should be possible to recreate all the remotes in a new repository and things would just keep working.
Johan Sørensen February 27th, 2008 @ 10:21 PM
That migration plan looks doable, I’ll hook you up.
Leslie P. Polzer February 28th, 2008 @ 03:07 AM
Have you checked out Mercurial? It might not be as suitable as Git for very large files, but it might actually solve your problems…
Brad Fults February 28th, 2008 @ 06:45 AM
As for an analog to
svn exportyou might want to check out thegit-archivecommand. Gitweb is pretty depressing. Try cgit.Tv February 29th, 2008 @ 08:26 AM
Why wouldn’t “git archive … | tar xvf -” be enough to replace “svn export”?
Koz February 29th, 2008 @ 05:50 PM
Thanks for the git-archive ref guys, it could well be the missing link.
@Leslie: Unfortunately we have a revision which mercurial cannot import. http://dev.rubyonrails.org/changeset/2587 Not sure if that’s improved since I last tried. http://hg.koziarski.com has more info.
Glenn Rempe March 1st, 2008 @ 02:43 PM
re: your need for a ‘A reliable read-only svn mirror based on our git repository’...
Perhaps you can use a technique like this for pushing a copy of the Git repo to a read-only SVN repo:
http://blog.nanorails.com/articles/2008/1/31/git-to-svn-read-only
I am using this technique for the Authorization plugin where the master is pushed from Git to GitHub.com and a local branch checkout of master is pushed with a ‘git svn dcommit’ to a Google Code SVN repo (read-only).
See both repo’s here:
http://github.com/DocSavage/rails-authorization-plugin/tree/master http://code.google.com/p/rails-authorization-plugin/source/browse
I really look forward to full Git support in Rails. So much better than SVN.
Cheers
Glenn
Hans-Peter March 4th, 2008 @ 11:54 PM
Did you checkout Redmine? We are switching from trac to redmine and love it. Besides it is written with rails (but we would have switched to redmine even if it was written in Fortran… ;-)
Jonas March 5th, 2008 @ 01:43 PM
Why not use SVK? It’s often overlooked but may (just may) provide the gains you seek without the cost of switching to git or Mercurial. It is, however, not as sexy buzzword-wise :-)