简体   繁体   English

Svn - > git迁移与几个主干/分支/标签

[英]Svn -> git migration with several trunk/branches/tags

I have a single SVN repository with the following current structure: 我有一个SVN存储库,具有以下当前结构:

  • project1 PROJECT1
    • branches 分支机构
    • trunk 树干
    • tags 标签
  • project2 项目2
    • branches 分支机构
    • trunk 树干
    • tags 标签

which originally had this structure: 最初有这种结构:

  • project 项目
    • branches 分支机构
    • trunk 树干
      • proj1 proj1
      • proj2 proj2
    • tags 标签

That is, the project was split into two separate "subrepositories" (or whatever you want to call that) 也就是说,该项目被分成两个独立的“子存储库”(或者你想称之为的任何东西)

Is there any way to migrate this to git without losing history ? 有没有办法将此迁移到git 而不会丢失历史记录 Would svn2git be better that git-svn for this scenario? 对于这种情况,svn2git会比git-svn更好吗? Is there any other migration tool? 还有其他迁移工具吗?

EDIT : I tried git svn clone as suggested but, as I thought, it didn't follow the move from the old structure to the new one. 编辑 :我按照建议尝试了git svn clone,但是,正如我想的那样,它并没有遵循从旧结构到新结构的转变。 It only imported the revisions from the new structure. 它只导入了新结构的修订版。

First I converted the main trunk to git: 首先我将主干转换为git:

git svn clone url-to-project -s

Then I converted each project: 然后我转换了每个项目:

git svn clone url-to-project1 -s
git svn clone url-to-project2 -s
...

Then for each project I attached the previous history from the main trunk using grafts and filter-branch. 然后,对于每个项目,我使用移植物和过滤器分支从主干附加了先前的历史。

I just blogged about it . 我刚刚在博客上写了这篇文章

svn2git just uses "git svn" underneath, so it won't be "better" per se. svn2git只是在下面使用“git svn”,所以它本身不会“更好”。 It just makes nice tags and branches and cleans things up for a clean break from svn. 它只是制作漂亮的标签和分支,并清理干净的svn。 If that's what you want, I'd go ahead and use it on the two sub-repositories individually. 如果这就是你想要的,我会继续单独在两个子存储库上使用它。 It will get all of the appropriate history. 它将获得所有适当的历史记录。

Did you already try the built-in 你有没有试过内置的

git svn clone

git-svn GIT-SVN

Your "current" structure already has all the history from the previous structure. 您的“当前”结构已经包含了之前结构的所有历史记录。 So, cloning each project using git svn clone should work fine. 因此,使用git svn clone克隆每个项目应该可以正常工作。

There won't be any need to tell Git about the previous structure with multiple projects under the trunk directory. 没有必要告诉Git在trunk目录下有多个项目的先前结构。

The great thing about Git is that you can try the migration as many times as you like until you're satisfied with the outcome. Git的优点在于,您可以根据自己的喜好尝试迁移,直到您对结果感到满意为止。

Use git svn clone -s SVN_REPOS to have git clone the Subversion repository assuming a standard Subversion layout. 假设使用标准的Subversion布局,使用git svn clone -s SVN_REPOS让git克隆Subversion存储库。 You will get a local git branch called master, but git branch -a will show you all the remote branches. 您将获得一个名为master的本地git分支,但是git branch -a将显示所有远程分支。 Subversion branches will just have the branch name, but tags will have a branch name of tags/tag_name . Subversion分支只有分支名称,但标签的分支名称为tags/tag_name

Don't reuse branch/tag names when cloning locally! 在本地克隆时不要重复使用分支/标记名称! git doesn't like that. git不喜欢那样。

This guide helped me a lot. 这本指南对我帮助很大。

http://www.viget.com/extend/effectively-using-git-with-subversion/ http://www.viget.com/extend/effectively-using-git-with-subversion/

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

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