Web pages of Lars Relund Nielsen

Migrating from svn (R-forge) to git (GitHub)

I recent migrated my R package mdp from my R-forge svn repo to GitHub. Do the following:

  1. Create an empty folder mdp and open a shell and import the svn to git (I only imported the pkg sub-folder svn+ssh://relund@svn.r-forge.r-project.org/svnroot/mdp/pkg)
    git svn clone svn+ssh://relund@svn.r-forge.r-project.org/svnroot/mdp/pkg .     # import the svn
    git branch -a    # info, should show a git-svn remote branch
    git svn info     # show svn details (also URL)
  2. Now add your local repo to GitHub. First, create an empty GitHub repo and next run from the shell:
    git remote add origin https://github.com/relund/mdp.git
    git push -u origin master

    The first line tells Git that your local repo has a remote version on GitHub, and calls it “origin”. The second line pushes all your current work to that repo.

Now you have a local Git repo and 2 remote repos (one at GitHub and one at R-forge). You want to use GitHub as the main repo. That is, add files, make changes to the master branch and commit to the master branch and GitHub as usual. At some point in time you want to commit the current revision to the remote svn repo at R-forge (so that the package can be checked at different OS etc.):

git svn info               # show svn details (also URL)
git svn dcommit –-dry-run  # show which svn branch you will commit into:
git svn rebase             # pull changes from svn repository
git svn dcommit            # push your local git commits to svn repository


Leave a Reply