This is the process to migrate an SVN repository to a Git repository. Adjust paths to your particular scenario.
Create a Git repository, but do not add anything to it. It must be bare. For example, if on GitHub do NOT add any ignore or readme files.
It is IMPORTANT that you do NOT go through the steps to clone the newly created repository or add anything to it. We are going to import the migrated SVN repository into it.
Now we need the SVN authors in nice Git format – store for safekeeping as it will be used later
1 2 |
|
To cover scenarios ambiguous scenarios add a ‘no author’ with an email of your choosing.
Somewhere safe make a temporary working area
1
|
|
Pre-prep the SVN repository (locally), this has some additional options as an example
1 2 |
|
Create a bare Git repository
1 2 3 4 5 |
|
Push the pre-prep SVN repository to the newly created baremig.git
1 2 3 4 |
|
Rename ‘trunk’ to ‘master’
1 2 |
|
Migrate the SVN tags
1 2 |
|
Push the bare repository
1 2 3 |
|
If the SSH ‘git remote add’ command does not work, try this one
$ git remote add origin git@github.com:<username>/<repo>.git
Push the tags to
1
|
|
Now go check it out. Once verified you can delete the local temp directory you worked from.
Tips, Tricks and Hints
SVN Command Line Error
If using the latest Xcode (version 4.6.2) and command line tools (/usr/bin/svn) with a Subversion version of 1.6.18 and you receive errors trying to check out the SVN repository
- Go to Homebrew and install Subversion – use this svn (/usr/local/svn) instead of /usr/bin/svn – that is make sure /usr/local/bin comes before /usr/bin in your PATH
Git SVN Command Line Error
When running the ‘git svn’ command and it errors out immediately you probably have to update the Perl SVN::Core CPAN module
- It will create ~/.cpan as root which can then chwon -R once done (I think it’s OK to remove it, though, but probably best to wait until everything is completed)
1
|
|