jump to navigation

Import Git to Subversion October 6, 2009

Posted by maxmil in : git , trackback

There are lots of docs out there for how to use git-svn starting with a subversion repository that already exists, however not so many if you are starting with a git repository that you want to import into subversion.

I still consider myself a beginner with git but here is how i managed it.

1) Create and import an empty subversion repository.mkdir tmp
mkdir tmp/my-project
mkdir /my-project/trunk
mkdir /my-project/tags
mkdir /my-project/branches
svn import tmp http://some/svn/repo -m "Initial import"

2) Clone a git repository from the subversion one you just importedgit svn clone -s http://some/svn/repo/my-project(The -s tells git svn that you are using a standard layout for branches, tags and trunk).

3) Enter your new svn enabled git repositorycd my-project
4) Add your working git repository as a remote repository.git remote add dev /path/to/working/git/repository
5) Pull all the commits from your working git repository into the master branch of the new repostory.git pull dev master
6) Rebase these commits ontop of the initial svn commit.git svn rebase
7) Commit changes to svn.git svn dcommit (Note that you can use the -n option to check first the commits that are about to be committed).

And that should do it, you can now remove the remote repository dev from your new svn enabled repository and carry on working using git svn dcommit to push local changes to the subversion repository.

Comments»

1. Pratik - December 1, 2010

Awesome, thanks a lot, this is the first one that worked after hunting around the internet for an hour!

2. Mike - June 10, 2011

Thanks… works great.

3. Aleksandar - January 31, 2012

This is great, thank you for posting this. It saved my life on few occasions.