reverse engineered

Git SVN Mirror

Git is a version control system for managing source code. It is notable for originally being written by Linus Torvalds to manage the Linux source tree.

While Git is arguably one of the best control systems around, there are many projects still using SVN. If you find yourself accustomed to Git, moving backwards to SVN can cause problems. Luckily, Git has a solution. Git is capable of interacting with SVN repositories directly. This allows you to checkout a remote SVN repository in to a Git repository on a local machine, make your changes, and commit back to the remote SVN repository. This means that you never have to interact using SVN syntax. You can also create a Git mirror of the SVN project, and publish it using a provider such as Github.

I currently use this to provide a Git mirror of lcd4linux. This is a one way mirror, but this adequate for most open source projects where patches and a mailing list are used as a the main source of updating code.

First create and initialise the git repo, then pull in the svn repo into git:

mkdir lcd4linux
cd lcd4linux
git svn clone

This can take a while depending on the size of the svn repo, and the amount of commits.

Create your project on Github, and add this as a remote repo to your local repo.

git remote add origin

Now push this to your remote repo:

git push origin master

The svn repo can now be checked for commits using:

git svn rebase

These changes can now to be pushed to your remote git repo using the same command as above:

git push

These commands can be automated using cron to provide an automatic update. Save the following shell script, and use cron to call the script every 15 minutes:


cd /home/jmccrohan/lcd4linux
git svn rebase
git push

Call cron every 15 mins:

*/15 * * * * /home/jmccrohan/lcd4linuxrebasepush >> /dev/null 2>&1

comments powered by Disqus