Git Svn Mirror

From GnuCash
Jump to: navigation, search

GnuCash has been using an svn repository as a primary repository, which is mirrored in a git repository on This brings some of the advantages of git over svn to the GnuCash developers. For this to work, a special mirroring configuration has been set up.

This page is mostly for documentation in the event that for some reason someone else needs to take over updating from subversion, or someone from another project happens upon this and wants to do the same themselves.

Setting up and Maintaining the Mirror

Download git-svn-mirror and gnc_authorsput it on your path.

If you're taking over updating, set up a committer's clone (see above) to get started from. Adjust the config file to look like this:

   repositoryformatversion = 0
   filemode = true
   bare = false
   logallrefupdates = true
   ignorecase = true
 [svn-remote "svn"]
   url = svn+ssh://
   fetch = gnucash/trunk:refs/remotes/svn/trunk
   branches = gnucash/branches/*:refs/remotes/svn/*
   tags = gnucash/tags/*:refs/remotes/svn/tags/*
   prefix = svn/
   authorsfile = /home/you/gnc_authors.git
 [remote "origin"]
   url =
   fetch = +refs/remotes/svn/*:refs/remotes/origin/*
   push = refs/remotes/svn/*:refs/heads/*

Note the "you" in the svn URI and the authorsfile path. The authorsfile path is wherever and whatever you name the author file, but the svn URI is critical. It must be the same URI that developers use to commit to the svn repo. See below.

Now you can run

 git-svn-mirror update /path/to/git-repo

to test it. If everything works, you can add it to a cron job and you're done.

If you're starting from scratch, there's a little prep work, mostly involving setting up the authors file. Instructions are in the git svn documentation; git-svn-mirror is a perl program and is documented with "Plain Old Documentation"; you can read it with git-svn-mirror man. The important thing to remember is that you should run git-svn-mirror clone only once; even if it doesn't completely succeed, always run git-svn-mirror update on an existing mirror.

Another note is that large subversion repositories take a long time to fetch; Gnucash's took 10 solid days on a 2.8GHz 4-core Mac Pro when there were 20,000+ revisions.


A bit of explanation about the svn URI.

Git svn writes an id at the bottom of each commit message that looks like

 git-svn-id: svn+ssh://  57a11ea4-9604-0410-9ed3-97b8803252fd

It doesn't put that in the svn repository, of course. When git-svn-mirror runs git svn to retrieve the changesets, it regenerates the id. If the URI and repo UUID (that long number at the end of the line) don't match, it will generate a different hash and when the submitter updates, git won't recognize them as the same change, which will make a mess of the submitter's local repo.