Unfortunately, there are a lot of CI/CD systems built with the SVN, we have to migrate these systems before users start using GIT instead of SVN. To poll hourly, add something like this to the git user’s crontab: 0 * * * * (cd /usr/local/git/repositories/svn-mirror/foo /usr/local/bin/git pull origin master /usr/local/bin/git svn dcommit) >/usr/local/git/gitorious/log/svn-mirror.I have huge and old SVN repository (50G+, 130k revs) and try to migrate it to GIT.
In theory it should be possible to set up post-receive hooks to push from the gitorious repository to the clone and from there to subversion, but I decided to separate the two by just periodically polling for changes, as we don’t really care about subversion being right up-to-the-minute.
To allow pushing to svn from master, rebase master to the svn branch (which can then be deleted): git checkout masterĪt this point you should be able to manually update subversion at any time by running git svn dcommit from the master branch. You’ll probably want to go and make a coffee or something while the dcommit runs – if you haven’t used subversion for a while you’ve probably forgotten just how much slower it is than git. You can now merge in all your commits from master, and push them to subversion. Now do an initial fetch of the empty subversion remote, and check it out as a new git branch (called svn): git svn fetch svn git/config (with the correct svn URI, of course): For this example, we’ll use a repository called foo/mainline.git.Ĭreate the clone: git clone ~git/repositories/foo/mainline.git ~git/repositories/svn-mirror/foo The repositories we want to mirror are in ~git/repositories, and we’ve created a directory ~git/repositories/svn-mirror where we’ll put the clones. If you’re not mirroring a bare repository, you can omit this step. To get round this, we create a clone, which we’ll use as an intermediate step in the mirroring process.
This is a bare repository, which makes things a little tricker, as git-svn requires a working copy. In our case, we have a central repository running on a local installation of Gitorious. This step, and subsequent ones, need to be performed on whichever git repository you want to mirror from. Once this is done, you can throw away the directory you checked out of subversion. Once you’ve got an empty repository to point to (we’ll imagine it’s at ), you also need to commit an initial version (I also created a trunk directory in this step, in case we later decide to mirror branches too): svn co Create subversion repositoryĬreate the subversion repository in the usual way, using svnadmin. You need to have git-svn installed (this comes with the default installation, or you can use the +svn option when installing via MacPorts). This is only intended to be a one-way mirror – I wouldn’t recommend also trying to commit into subversion and merge those commits back upstream into git.
The end result should be a subversion trunk which is a mirror of the git repository’s master branch. The simplest one was this Nano Rails blog post, which is what the steps below are based on. This isn’t entirely trivial to do using git-svn (which is really intended for use with subversion acting as the master), but I found a few sets of instructions on the web.
We lost the battle to get corporate approval for git (apparently we’re happy to employ people to write our code that we wouldn’t trust to be able to use a DVCS), but at least we have agreement that we can continue using git as long as we mirror the code into subversion. Our team been using git at work for the past couple of years, but there’s now a corporate push to keep everything in a centrally-managed subversion repository.