SVN to (BitBucket) Git migration

Notes from the migration of my personal SVN repo to Git and also onto the hosted Git platform Bitbucket.org.

First step was to tell my local git install who I was:

$ git config --global user.name "Robin Kearney"
$ git config --global user.email "robin@kearney.co.uk"

I always set the following too:

$ git config --global color.diff auto
$ git config --global color.status auto
$ git config --global color.branch auto

Then to import a section of my SVN repo:

$ git svn clone --authors-file=path/to/authors_file SVN_REPO_URL LOCAL_DIR
$ cd LOCAL_DIR
$ git svn show-ignore > .gitignore
$ git remote add origin git@bitbucket.org:rk295/GIT_REPO.git
$ git push origin master

Some people advise using -s on the ‘git svn’ command, which tells git to expect trunk/ tags/ etc. But I dont use those in my repo, so I omitted it.

SVN_REPO_URL is the full http://…. URL to the SVN repo to import, or in my case a sub-section of it.

The --authors-file tells git the location of a text file which maps SVN users to Git users, mine looked like this:

robin = Robin Kearney <robin@kearney.co.uk>

2 Comments

  1. Dmitry says:

    With git-svn you’ll lose all your svn:ignore, svn:eol-style, tags and get strange history for replaced branches. SubGit or SmartGit are better alternatives to git-svn for migration.

  2. robin says:

    Thats for that tip, I’ll look to try one of those next time I fiddle with Git. I got my repo moved over, but I didnt have time to update some of my support scripts, so I’ve yet to migrate fully.

    r.

Leave a Reply