Git Svn

2 minute read

From my old Git(hub) notes…

git and svn

Github and git and really nice and despite git’s additional complexity, my preferred solutions for a few years now. Nevertheless, subversion is still around and much used. Since some projects are hosted by third parties using svn, but I still want to use Github, I tried to initialise git and checkout svn in the same directory. This hybrid versioning solution, which keeps the two version controllers completely independent, seems to work quite well. The only little tweaks are to ignore the respective .git and .svn directories. The latter in easy with the .gitignore file. Ignoring files in svn is not that straightforward. One needs to set properties on the files/dirs to be ignores and, what was confusing to me, commit these to the server. Here are three posts [1, 2, 3] that helped me to realise how to this and will hopefully prove helpful next time I have to repeat this.

git-svn

This is obviously the sophisticated solution, that enable to merge and preserve the respective commit message. These [1, 2] were the most helpful resources. There is also of course the Pro Git book with a git-svn section. This documentation was migrated to the Bioconductor BiocGithubHelp wiki page.

git-svn lola

Bitbucket to Github migration

Moving code from Bitbucket to Github is straightforward. But there is much more than just code in such a project. In my case, I had issues I really wanted to preserve, and I could not find any easy way to do it (as of the time of writing). There were scripts to migrate issues and bug tracking between different providers, but not exactly what I needed. Had to read about the respective APIs to do it manually, which was not too difficult. Briefly, here is a summary of what I did, more or less:

  1. Download issues locally as described here. The issues need to be public, though.

       curl https://api.bitbucket.org/1.0/repositories/:user/:repo/issues/1/ > myissue1.json
    

    (where :user and repo are my/your user and repository names respectively).

  2. Unfortunately, the json issues are not compatible: Bitbucket’s content is called body by Github (there might be more…). A bit of perl magic did the trick here.

       perl -pi -e 's/\"content\":/\"body\":/' issue*.json
    
  3. Post the issues on Github following the API docs:

       curl -u ":user:password" -X POST -d @issue1.json ttps://api.github.com/repos/:user/:repo/issues
    

It is far from perfect; comment were missing! Fortunately, there were only very few issues with relevant comments (most closing comments were fixed in version x.y.z), so I did not dig deeper. The above steps were embedded in a short shell script to automate the 30ish issues to be moved. Hope that next time I need to do this, somebody will have a great script ready, or at least this will prove helpful.

Leave a Comment