iCoreTech Research Labs Just a placeholder

20Aug/091

How to mirror a SVN repository on GitHub

Start by creating a project on github.
In this example we will mirror Sphinx search engine.

On your server or local machine create a new git repository, with the same name of the github repo.

mkdir ~/src
mkdir ~/src/sphinx
cd ~/src/sphinx
git init

Now setup the SVN repository as a remote source to track.
It should be noted that the '-T' switch points git directly to the trunk, which is fine for our purposes.

git svn init -T http://sphinxsearch.googlecode.com/svn/trunk

Perform the initial pull.

git svn fetch

This will take some time, based on the size of the remote repository.

After the first pull is finished, go ahead and run the garbage collector, this will help to speed up things and reduce size.

git gc

I'm going to use a different public key for pushing to github, with no passphrase.

ssh-keygen -t dsa -f ~/.ssh/id_dsa_github_for_mirroring

Now, edit '.ssh/config' and add

Host githubmirror
User git
Hostname github.com
IdentityFile /home/yourusername/.ssh/id_dsa_github_for_mirroring

Now, copy and paste your public key into your github account.

cat ~/.ssh/id_dsa_github_for_mirroring.pub

Add the origin, do the first push.

git remote add origin git@githubmirror:yourgitusername/sphinx.git
git push origin master

To keep stuff in sync we need to do

git svn rebase
git push origin master

This is an operation you should do every X minutes or so.
Better setup a cronjob to handle that.

mkdir scripts
cd scripts
nano mirror.sh

and add the following:

#!/bin/sh
cd /home/yourusername/src/$1
git svn rebase
git push origin master

Save and close the file.

Now edit a crontab entry:

crontab -e

Press 'i' and start pasting this line:

*/15 * * * * /home/yourusername/scripts/mirror.sh sphinx >/dev/null 2>&1

Press 'ESC' and digit ':wq!' to exit.

This is the actual result.

Related posts:

  1. Hosting Git repositories through WebDAV on Snow Leopard Server
  2. How to install Sphinx search engine in Snow Leopard, x86 and x86_64
  3. My Rails .gitignore
  4. Know how many users committed into a git repository

Tagged as: , , Leave a comment
Comments (1) Trackbacks (0)
  1. I like both the Gamecube and Xbox, we have them in our home office and also in our living room.-”.


Leave a comment


No trackbacks yet.

Additional comments powered by BackType