开发者

Migrating a multi-project Subversion repo with a common trunk to Git?

开发者 https://www.devze.com 2023-02-16 10:50 出处:网络
I began using Git last year and have enjoyed it so much that I\'m considering switching over my largest, most active Subversion repo.Unfortunately, that repo contains several (related, but independant

I began using Git last year and have enjoyed it so much that I'm considering switching over my largest, most active Subversion repo. Unfortunately, that repo contains several (related, but independant) projects.

There are many, many pages describing how to convert a single-project repo, but far fewer for multi-project repos. In fact, I've only found a few, and they all seem to assume that each project has its own trunk:

project1/
    branches/
    tags/
    trunk/
project2/
    branches/
    tags/
    trunk/
project3/
    branches/
    tags/
    trunk/

Regrettably, my Subversion repo looks something like this:

branches/
    *empty*
tags/
    project1-0.9/
    project1-1.0/
    project1-1.0.1/
    project2-0.9/
    project2-0.9.1/
    project3-0.5/
trunk/
    project1/
    project2/
    project3/

Worse, the tags are all created from the working copy (e.g. svn copy . svn://example.com/svn/tags/project1-1.0.2), so include small changes never commited to the trunk (mostly hard-coding vers开发者_StackOverflow社区ion numbers). Also, there are a handful of commits which span all projects (license updates, etc.). Thankfully, at least, there are no merges!

Is there a clean way to untangle these projects while keeping my tags? If it helps, this would be a one-way conversion, with the Subversion repo taken offline afterward.


I used http://gitorious.org/svn2git/svn2git to do the very same thing. This tool was originally created to convert the huge KDE SVN repository to Git, which BTW is also laid out as your repository. All you have to do is writing a simple control file describing which directories correspond to which project and branch. In the end you have a nice set of git repositories for your projects.

One note though: There is no direct support for SVN tags. You will have to import them as Git branches and postprocess them, cf. http://gitorious.org/svn2git/svn2git/blobs/master/samples/merged-branches-tags.rules.


http://repo.or.cz/w/svn-all-fast-export.git seems to take extensive rules files that can sort out your repository. I know from using git-svn (bidirectionally) that you can prune out substantial parts of the svn repo with no problems (including ignoring parts of a commit due to the svn root pointing deep into the repository or via --ignore-paths).

After you make your new repo you can use git-submodule to tie the back together if there are cross references.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号