This page would have showed how to copy an entire Subversion repository from one location to another using Git. Unfortunately, git is not expressive enough to be a good intermediary between two Subversion repositories. There are a number of efforts underway to fix this, however, so hopefully news will be better in a year.

Introduction

What happens when you no longer have shell access to your svn repository? No problem! We'll use Git to pull down all the changes from one repository, then push them all up to another.

svnsync can do this too, of course. I just wanted to try Git before resorting to something that I already know would work. :)

Download the Old

Download every single revision into a new local Git tree. See Git/git-svn#Sync_Git_Repo for some hints on dealing with especially large repositories

 git-svn clone svn://svn.berlios.de/tmtest

Git doesn't remember empty directories, svn does. Also, the only property that git-svn recognizes is svn:executable. It logs everything that it has chosen to ignore to $GIT_DIR/svn/<refname>/unhandled.log. Check here to see any information that Git is about to drop. You can probably ignore "svn:mime-type application/octet-stream" properties -- git is pretty smart about deciding what's a binary file.

Difficulties

In particular, if you have svn:externals in your repository, Git will definitely throw them away, potentially breaking the build.

Hopefully gitattributes (versioned properties able to be attached to any tree object) can be used to track all subversion properties. Already, in 1.5.2, the plumbing is in place for "svn:mime-type application/octet-stream," git-svn just needs to start using it.

TOFIX: git-svn needs to create .gitignore files for each imported revision, then delete them when pushed. Also, put the paths to ignore into the .gitignore file on import, then convert them back to svn properties on export. Should hook up svn:mime-type. This handles empty_dir and svn:mime-type. I'm not sure how svn:external would be handled though!

Strictly speaking, svn:mime-type could be used to set a file to any mime type. However, I've only ever seen a single mime-type set for this property, application/octet-stream to indicate a binary file. Therefore, handling this with the new 1.5.2 property should take care of 99.9% of current usage.

The new subtree feature might be able to handle svn:externals.

Result

Unfortunately, the shortcomings to using Git for this task are too great. I'm going to use svnsync.

Verify

Now I'd like to use svn to make sure that each changeset is identical.