Devlog :: And Wizardry

Mon, 29 Mar 2010

Moving Subversion repositories to Git

Mostly FMI (for my information)...

I've been wanting to check out git for a while and the time was right. I'll be moving one of my server accounts soon. That includes some Subversion repositories. It's not too hard to move svn to a new server but it turned out to be even easer to port it all to git.

Here's what I did:

[There are lots of ways to do this, but this worked for me...]

> git svn clone svn+ssh://user@pwizardry.com/rest-of-svn-style-url

This creates a new git repository in the current directory with the same name and all the contents of the Subversion repository, including all the revision history. A lot of stuff scrolls by listing every commit and every file involved.

It died for me part way through with this encouraging message: error: git-svn died of signal 13 which is from an unresolved bug. If you cd to the new repository and type

> git svn fetch

it will continue where it left of.

What I had when this was done was a git working copy. This includes all the diffs and objects that make a repository, plus a copy of the current versions of all files and directories. What I wanted was a "bare" repository on my server that doesn't have all the files. I'll use this to clone new working copies of my code where I will be working on it and then pushing changes back.

For example, on my laptop:

> git clone ssh://munging.us/xxx/local/git/cell
[hack, hack]
> git commit -a -m "I hacked and hacked"
> git push ssh://munging.us/xxx/local/git/cell or just git push origin

Getting back to making a bare repostiry... It would be nice if git svn took a --bare option, but it doesn't. The trick is to clone a new bare copy with a different name and blow away the original. Then rename the clone with the original name.

> git clone --bare cell cell.temp
> rm -rf cell
> mv cell.temp cell

With all the warts showing in the first few git commands I typed, I had to wonder if it was ready for prime time! To be fair this was all in the git-svn command which, in the end, did an impressive job for me. One command and some cleanup (and a bunch web searching) did the trick. Bringing over the rest of my svn repositories was easy.

git!

[/items/hacks] permanent link