A simple way to import commits from git to svn
Disclaimer: I’m posting this because when I googled for a quick solution for importing a few git commits into subversion there was nothing. This might not be perfect, but it worked for me.
The basic idea is to output the patch files from git. This will export a patch file for each commit between these two shas
git format-patch --no-prefix sha1..sha2
Then apply the patch, add and remove everything, and commit
patch -p0 < commit.patch
# Mess about a bit
svn commit -m commit
I wrote a quick ruby script to automate this which you can find at http://gist.github.com/350524. After running git format-patch to create the patch files just run the script in the subversion directory
ruby ~/bin/import_git_patches.rb "/glob/for/patch/files/00*"