tags:

views:

129

answers:

1

Disclaimer: Things would be simpler had I known about git-svn at the start.

I had a large codebase in SVN, and crudely got it situated in git. Work life was very painful without fast, efficient branching, so this was all accomplished in a bit of a rush. My process was:

svn export
git init .
git add .
git commit -a -m "initial commit"

Now I'm done with my small branch projects. I was able to "fight fires" in a clean branch and do development on others. It was great. My branches are all now merged back into one, and I'm ready to get this code back into SVN.

I've worked a bit with git-svn now, having gotten the svn repo setup and fetched. But that's as far as I can get.

Assuming my git branch is "master", and my git-svn repo is "svnrepo":

git checkout master
git rebase svnrepo

fails and throws masses of merge conflicts and "already exists in index" errors.

git checkout svnrepo
git rebase master

fails exactly the same way.

How can I preserve git history and get this code back into SVN?

+1  A: 

I would do a sequence of git cherry-pick operations on your "svnrepo" branch to move over each relevant commit from the "master" branch (starting with the oldest). Cherry picking is largely agnostic regarding the ancestry of each commit, and will try to apply the patch without being concerned where it came from. Once you have finished cherry-picking all the commits, use git svn dcommit to commit them to Subversion.

Note that if you have any nonlinear history on the "master" branch, you will want to try to flatten this out before pushing your code back up to Subversion. This may require a bit of extra work but since Subversion doesn't support nonlinear history, it's pretty much a required step.

Greg Hewgill