This document details the procedure for a permanent migration from SVN to Git.
- Create authors file to map usernames to authors
- Clone SVN repository to Git using
git svn
- Severe connection to SVN remote
- Convert tag branches to Git tags
- Set up Github remote as origin and push
# Checkout the original repository
$ svn checkout [SVN repo path]
$ cd repo-name
# Get list of committers for authors.txt file
$ svn log --quiet | awk '/^r/ {print $3}' | sort -u > ../authors.txt
#
# Edit "authors.txt" to match the following format:
#
# {{ svn username }} = {{ git name }} <{{ git e-mail}}>
#
# e.g.
# joeuser = Joe User <joeuser@bu.edu>
#
# Clone SVN repository using Git
$ git svn clone [SVN repo URL] [temporary working dir] --stdlayout --no-metadata --authors-file=authors.txt
#
# NOTE: It will fail if it encounters any user names that are not in authors.txt.
# If this occurs, add the missing author(s), remove the newly-created git directory, and restart the clone.
#
# NOTE 2: Authorless commits will fail, as above. Workaround: add the following to the authors.txt file:
# (no author) = no_author <no_author@no_author>
# Setup local branches for all remotes
$ git fetch . refs/remotes/*:refs/heads/*
# Delete all remote branches
$ for branch in `git branch -r`; do git branch -rd $branch; done
# Delete local "trunk" branch
$ git branch -d trunk
# Remove git-svn configuraiton / files
$ git config --remove-section svn-remote.svn
$ rm -Rf .git/svn/
# Set up Git tags for each of the tag branches, then remove those branches
# e.g.
$ git tag -am 'Release 1.4.4' 1.4.4 02b0e0e0b8
$ git branch -D tags/1.4.4
# Set up Github remote as origin and push
$ git remote add origin [GIT URL]
$ git push origin --all