Alex Rivera | Logout

Convert SVN Subdirectory to Git

Asked 2010-05-02T01:32:25.883
29

I would like to ditch SVN for Git. My current SVN repository setup has projects under trunk (/trunk/projecta, /trunk/projectb, etc. with tags and branches at /tags/projecta-1.0, etc.). I would like to create distinct Git repos for each of these projects by pulling them out of SVN using git-svn.

I've successfully pulled the entire SVN repo down to a local Git repo but all of the projects exist in the same Git repo now. Is it possible to pull them apart at this point?

Edit
Report

2 Answers

20

This is tricky. To get, e.g., the tags for a project, all its tags have to be under a common directory, but your structure has all projects sharing a single tag directory.

Perhaps you could move /tags/projecta-1.0 to /tags/projecta/1.0 and so on, and then import projects into git one at a time:

git-svn init --trunk=trunk/projecta --tags=tags/projecta ...

I don't know if this will work as expected, so please do this on a copy of your repository, not the original!

answered 2010-05-02T02:43:39.437
5

I recently had to solve this problem with a reasonably complex case (extracting the utahrle files from BRL-CAD's overall history to make a separate GIT project) and ended up using svn2git with a rules file. These were my steps - not sure if it's the "right" way but it seems to have succeeded in my case:

  1. Make sure svn2git is installed, as well as subversion and git (enable git subversion support if not already present.) Note that there seem to be multiple programs using the project name svn2git - the one I used is this one:

    http://www.gitorious.org/svn2git

    This article from KDE got me started:

    http://techbase.kde.org/Projects/MoveToGit/UsingSvn2Git

  2. Obtain local copy of your svn repository. Note that this is not a checkout of the repository but a full copy of the entire SVN repo data set. Sourceforge makes this possible with an rsync option - see their docs for details: http://sourceforge.net/p/forge/documentation/rsync%20Backups/. I'm not sure about other sites.

    mkdir svn_repo
    cd svn_repo
    rsync -av svn.code.sf.net::p/PROJECTNAME/MOUNTPOINT .
    cd ..
    
  3. create identity map between svn committers and git committers

    file: account-map

    svnname1 Jane Coder <coder@foo.org>
    svnname2 Joe Techwriter <writer@foo.org>
    
  4. create svn2git filtering rules to capture the utahrle history. I'll post the full utahrle example here that shows how to follow the history around between different directories, but I'd expect most cases wouldn't be quite this bad:

    file: rules

    create repository utahrle
    end repository
    
    match /brlcad/trunk/libutahrle/
       min revision
answered 2013-02-03T18:36:49.003

Your Answer