We'll use the Easy Digital Downloads plugin as an example.
First, we need to get the revision number of the first commit to the WordPress SVN repo, because otherwise Git will try to go through all 100000+ commits in order to find it.
svn log http://plugins.svn.wordpress.org/easy-digital-downloads/
It is the last commit revision you seen on the screen:
------------------------------------------------------------------------
r529177 | plugin-master | 2012-04-09 19:36:16 +0200 (Mon, 09 Apr 2012) | 1 line
adding easy-digital-downloads by mordauk
------------------------------------------------------------------------
In this case it is r529177.
Create a local Git repository for the plugin and import the first commit from the SVN repository:
git svn clone --no-minimize-url -s -r529177 http://plugins.svn.wordpress.org/easy-digital-downloads/
which returns the following:
Initialized empty Git repository in /Users/kaspars/svn2git/easy-digital-downloads/.git/
r529177 = e18c66d09d77e4d8a923f2f300f73606791071e1 (refs/remotes/trunk)
Checked out HEAD:
http://plugins.svn.wordpress.org/easy-digital-downloads/trunk r529177
Notice the --no-minimize-url
flag which is required to stop git svn clone
from moving into the base folder of the remote SVN repository and going through all plugins (see http://schacon.github.com/git/git-svn.html). We also use -s
which is a shorthand way of setting trunk, tags, branches as the relative paths, which is the Subversion default (from http://schacon.github.com/git/git-svn.html).
Move inside the newly created Git repository:
cd easy-digital-downloads
and fetch all the other commits from the SVN repo:
git svn fetch
This step will take hours (!), so you can use the GIT_TRACE=2
flag before the the command to see a more verbose output:
GIT_TRACE=2 git svn fetch
Once this process is finished you have a complete Git commit tree for the project.
git svn rebase
didn't work for me (it just hangs). I had to usegit svn rebase --all