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 fetchThis 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 gcI'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 masterThis 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 -ePress 'i' and start pasting this line:
*/15 * * * * /home/yourusername/scripts/mirror.sh sphinx >/dev/null 2>&1
Press 'ESC' and digit ':wq!' to exit.
Related posts:
- Hosting Git repositories through WebDAV on Snow Leopard Server
- How to install Sphinx search engine in Snow Leopard, x86 and x86_64
- My Rails .gitignore
- Know how many users committed into a git repository
Enjoy this article?
Additional comments powered by BackType
July 20th, 2010 - 20:14
I like both the Gamecube and Xbox, we have them in our home office and also in our living room.-”.