Recently, I moved my Zaapt repository from a Subversion repository on Google Code into a Git repository on my server.

Here's some (really) quick instructions on how I did it. I'll be using it as a quick guide later and it may come in useful for you too.

If you want more detailed explanations on hosting Git repositories, see Nigel's excellent and more in-depth explanation. His takes you through a lot more cases (including the continued use of SVN, whereas this is about cutting the line completely).

Notes:

  • the local machine is called 'alpha'
  • the remote machine is called 'beta'
  • you will access the repo over ssh+git
  • it is private and not public
  • you repo will be stored in /var/lib/git which is writable by you
  • the project is called 'zaapt' but replace that with your projectname

Firstly some setup:

 alpha$ cd /tmp
 alpha$ mkdir zaapt
 alpha$ cd zaapt
 alpha$ git-svn init http://zaapt.googlecode.com/svn/trunk/ --no-metadata

Then, you need to tell Git how to map Google Code usernames into commit names. I'm the only one who has commited to Zaapt so I just need one line:

 alpha$ cat > /tmp/users.txt
 andychilton = Andrew Chilton <andy@example.org>
 alpha$ git config svn.authorsfile /tmp/users.txt

Then you do the actual import. Two notes here. The first is that you don't want the initial repository version since that was created (as user nobody) when your Subversion repo was set up. The second I'm assuming you know the final version of your repo is 447:

 alpha$ git-svn fetch -r 2:447
 ...etc...

Earlier I said that we would be hosting our repository on our own server, so let's get a bare-bones repo without any of the SVN cruft left:

 alpha$ cd ../
 alpha$ git clone --bare --local zaapt/.git zaapt.git 
 alpha$ chmod +x zaapt.git/hooks/post-update
 alpha$ vim zaapt.git/description

Now copy the repo to your server. I'm assuming you want them in /var/lib/git:

 alpha$ scp -r zaapt.git beta:/var/lib/git

You're now done with everything we created in /tmp/ so remove them if you like. Now get a fresh clone of the new repo:

 alpha$ cd ~/git/
 alpha$ git clone ssh+git://beta/var/lib/git/zaapt.git

And if you want a checkout at the far end too:

 beta$ cd ~/git/
 beta$ git clone --local /var/lib/git/zaapt.git

That's it. Simple but it gets the job done for what I wanted it for.

For further reading, see Nigel's page above, Sam's extensive page on An introduction to git-svn... and Chris' page about publishing git repositories


This post originated on http://chilts.org/.

Email me on andychilton -at- gmail -dot- com.



Published

11 May 2008

Tags