Transfering Subversion repositories

Subversion repositories can be copied using the svnsync command that comes bundled with Subversion.

  1. Initialise the new repository:

    svnsync init NEW_URL OLD_URL

    This may fail if the new repository is not empty, or if the new repository does not allow modification of revision properties. If either of these are the case, contact the administrator of the new repository.

  2. Copy each revision to the new repository.

    svnsync sync NEW_URL OLD_URL

Alternatively, a Subversion repository can be converted to a Git repository using git-svn. You may need to install both git and git-svn.

  1. Git uses names and email addresses rather than usernames to identify comitters. Create a file called users.txt that maps the usernames in your Subversion repository to names and email addresses. The file should have the following format:

    jsmith = John Smith <>
    willj = Will Jones <>

    Note: If you have a machine with grep, sort and perl installed, you can use the following command to generate a list of author names:

    svn log ^/ --xml | grep '^<author>' | sort -u | perl -pe 's/<author>(.*?)<\/author>/$1 = /' > users.txt
  2. Clone your Subversion repository into Git format:

    git svn clone --authors-file=users.txt
  3. Move old SVN tags to be proper Git tags:

    git for-each-ref refs/remotes/tags | cut -d / -f 4- | grep -v @ | while read tagname
      git tag "$tagname" "tags/$tagname"
      git branch -r -d "tags/$tagname"
  4. Move the rest of the refs under refs/remotes to be local branches:

    git for-each-ref refs/remotes | cut -d / -f 3- | grep -v @ | while read branchname
      git branch "$branchname" "refs/remotes/$branchname"
      git branch -r -d "$branchname"
  5. Add your new git server as a remote and push to it:

    git remote add origin GIT_REPOSITORY_LOCATION
    git push origin --all
    git push origin --tags