Asleep from Day

June 5, 2008

git first, git-svn later.

Filed under: scm — John @ 5:18 pm

the whole story is that I started a project locally and I used git as my SCM. now I’m going to put it into a svn repository with full history but I still want to use git.

normally you should make this decision at the beginning. that means you
git-svn clone http://svn.somewhere.com/myproject
first, then you use git as usual, do git-svn rebase and git-svn dcommit. you have to do this because git-svn must know where to start, namely you should have at least one git-svn-id in your git log to start with.

here is how I add svn support into an existing git repository. basically it’s easy, you just
git-svn init http://svn.somewhere.com/myproject
git-svn fetch

now git branch -r should tell you there is a branch called git-svn. you git rebase git-svn your current master. if it succeeded then you’re all set.

however, in order to do this, there must be a point back in time that these two branches are the same. if it’s not the case, you’re in trouble. you have to use git-svn set-tree to force a svn commit to be your starting point. in my case, the svn repository started out empty, so I forced the first commit in my git. after that git rebase succeeded like I expected.

1 Comment »

  1. Interesting. I was looking for this very information.

    Unfortunately, I can’t seem to get the git-svn set-tree command to work.

    I have a blank SVN repository that I’m looking to push my local git repository into. I was able to do the git-svn init and git-svn fetch fine but I can’t seem to do a dcommit. I don’t have the remote git-svn branch in my list and I can’t get the set-tree command right.

    can you explain this command a bit more and how you got it to work?

    Comment by Dr J — September 3, 2008 @ 9:44 am

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.