简体   繁体   English

将具有公共中继的多项目Subversion仓库迁移到Git?

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

I began using Git last year and have enjoyed it so much that I'm considering switching over my largest, most active Subversion repo. 我去年开始使用Git并且非常喜欢它,所以我正在考虑切换我最大,最活跃的Subversion回购。 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: 遗憾的是, 我的 Subversion回购看起来像这样:

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 (eg svn copy . svn://example.com/svn/tags/project1-1.0.2 ), so include small changes never commited to the trunk (mostly hard-coding version numbers). 更糟糕的是,标签都是从工作副本创建的(例如svn copy . svn://example.com/svn/tags/project1-1.0.2 ),因此包含从未提交到主干的小更改(主要是硬编码版本)号)。 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. 如果它有帮助,这将是一个单向转换,随后Subversion repo脱机。

I used http://gitorious.org/svn2git/svn2git to do the very same thing. 我使用http://gitorious.org/svn2git/svn2git做同样的事情。 This tool was originally created to convert the huge KDE SVN repository to Git, which BTW is also laid out as your repository. 最初创建此工具是为了将巨大的KDE SVN存储库转换为Git,BTW也作为您的存储库。 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. 最后,您为项目提供了一套很好的git存储库。

One note though: There is no direct support for SVN tags. 但需要注意的是:SVN标签没有直接支持。 You will have to import them as Git branches and postprocess them, cf. 你必须将它们作为Git分支导入并对它们进行后处理,参见 http://gitorious.org/svn2git/svn2git/blobs/master/samples/merged-branches-tags.rules . 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. http://repo.or.cz/w/svn-all-fast-export.git似乎采用了可以整理存储库的大量规则文件。 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 ). 我知道使用git-svn (双向)你可以毫无问题地删除svn repo的大部分内容(包括忽略部分提交,因为svn根指向存储库或通过--ignore-paths )。

After you make your new repo you can use git-submodule to tie the back together if there are cross references. 在创建新的repo之后,如果存在交叉引用,则可以使用git-submodule将背面绑定在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM