Translate

Friday 7 November 2014

Subversion to github

A big part of the daily routine of a particle physicist is writing code. Unfortunately, we're not particularly well trained for this, so new developments trickle through the system rather slowly. Recently a couple of colleagues and I chose to re-start development of a package that had seen only little activity in a while. The code was hosted on subversion, together with dozens of other packages. For our project, we chose to migrate to github.

So here's a little review on how we got on:

  1. create github dir
  2. checkout old code from svn
  3. check new code into git
  4. commit code
  5. start applying some patches and start coding
At this point a colleague suggested that we should preserve the old commit history from subversion when importing the code. Terrific idea! But we already started coding... I'm lazy, so starting all over is clearly not an option. So here's what I did.
  1. Import the code from subversion into github including the commit history and existing svn branches and tags
  2. checkout the repository with our developments
  3. git log #gives you the history, together with the sha for each commit
  4. git format-patch -4 HEAD # to get patches for the last 4 commits. This creates 4 patch files
  5. git checkout <new repo from github import>
  6. cd <new repo from github import>
  7. apply the patches from step 4 one by one. I think the "git am" command would do all of this in one step, so that may be a better solution. I will try that next time.
At one point, there was a conflict in the merge. I have simply copied the conflicting file over from the other repo. Again, "git am" looks like it would have worked better. I'm still on the upward path of the learning curve.

No comments:

Post a Comment