Update Apr 2014
There is a tool called Svn2Git that does a pretty good job of making this process a bit easier. The documentation on the Github project is pretty good. (Ruby required)
It's worth noting that while git-svn defaults to pulling from just the path you specify, not branches, tags and trunk. Svn2git is the opposite. It will default to looking for a trunk, branches and tags under the path and you should use --nobranches
or --notags
to tell it not to search for those (though this may nullify the advantages of svn2git).
Once you move to Git, I suggest you move everyone and stay using Git. It's more complicated but the transition will be worth it. Github.com supports accessing the repo using an Subversion client (but you may loose the power of Git branching) and that might be a good stop-gap.
Can I keep my Subversion repo?
When you use the below method to move, all the current commits will remain in the Subversion repo. You may be able to do a one-way sync from the Subversion repo to the Git repo, but going the other way gets very complicated very fast. I would not recommend trying to sync either way and just move everyone one-time.
What's powerful about Git?
Git branching is powerful but it's not all there is to Git. Having a complete history locally means you can do everything you can do with Subversion, but without having to contact the server. Reviewing and searching the history, undoing changes, committing locally, branching locally become immensely faster. Git also compresses it's data, so a Subversion checkout (that includes only the latest revision) ends up being about the same size as a Git checkout (that includes the full history). Also, because data is compressed when transferred, pushing and pulling are much faster as well. Don't just push Git branches, put everything about Git.
How to move a repo using the git svn
method.
First, clone the Subversion repo. This might take a while.
git svn clone http://www.example.com/svn-repo/projectA/trunk/
Where http://www.example.com/svn-repo/
is the URL to the Subversion repo and projectA/trunk/
is the path you want to copy into Git.
If you have a standard layout such as projectA/trunk
, projectA/branches/
and projectA/tags/
than you can add --stdlayout
and clone from a directory up like this
git svn clone --stdlayout http://www.example.com/svn-repo/projectA/ projectA.git-svn
And, if you have a trunk, branches and tags folder named differently then above, you an give git svn clone
custom names for each.
git svn clone --trunk my-trunk --branches my-branches --tags my-tags http://www.example.com/svn-repo/projectA/ projectA.git-svn
Once that completes all you have to do is push to the remote git repo with --mirror
.
cd projectA.git-svn
git push --mirror git@github.com:Account/projectA.git
At this point you should make your Subversion repo read-only to keep people from trying to commit to an out dated location.