read-only git mirror of an svn repository read-only git mirror of an svn repository git git

read-only git mirror of an svn repository


I do that on a project that uses SVN (pushing to a public repository on github). I don't have a SVN commit hook, but this on a cron job:

#!/bin/bashrepo=/path/to/my-mirror.gitlockfile="$repo/cron-lock"if ! lockfile -r1 "$lockfile";then        exit 1fiexport GIT_DIR=$repo# update refs/remotes/git-svn:git svn fetch -q# make 'master' match the git-svn branch:git fetch "$repo" refs/remotes/git-svn:refs/heads/master# publish to githubgit push github masterrm -f "$lockfile"

If you trigger this from a SVN commit hook instead of a cron job, it should work.

Of course, you need to set up a remote called github using git remote add github [...]. The git repository I am using is a "bare" repository (see git init --bare).


The best way to set up an Svn/Git mirror (writable) would be to use SubGit - this is a tool specifically developed for this task. Disclaimer: I am the developer of this tool.