简体   繁体   English

使用svn2git将svn repo转换为git repo时更改文件夹结构

[英]Altering folder structure while converting svn repo to git repo using svn2git

I am migrating a SVN repository to Git. 我正在将SVN存储库迁移到Git。

The svn structure is like shown below svn结构如下所示

Root
  + branches
      + b1
      + b2
      + development_branches
          + d1
          + d2
  + tags
  + trunk

The situation here is the folder branches contains another subdirectory development_branches which in turn contains few branches. 这里的情况是文件夹分支包含另一个子目录development_branches,而该子目录又包含几个分支。

When I use svn2git, to convert this in to a git repository. 当我使用svn2git时,将其转换为git存储库。 The folder development_branches is considered a single branch. 文件夹development_branches被视为单个分支。 Below is the Git branch structure using svn2git 下面是使用svn2git的Git分支结构

Root
   + b1
   + b2
   + development_branches

is it possible to make svn2git to consider the contents of the folder "development_branches" as individual branches instead, or is there a way in Git which will enable to mark the folders inside the folder development_branches as individual branches? 是否可以使svn2git将文件夹“ development_branches”的内容视为单独的分支,或者Git中是否有一种方法可以将文件夹development_branches内的文件夹标记为单独的分支?

Thanks in advance 提前致谢

I am not sure if this is the right way of doing it, but it seems to work. 我不确定这是否是正确的方法,但似乎可行。 If this is not correct, your feedback are welcome. 如果不正确,欢迎您提供反馈。

The strategy is like this 1. Create branches from the branch "development_branches", one for each subfolder 2. check out the newly created branch and use the command git filter-branch to replace the root content with the contents of the subdirectory 策略是这样的1.从分支“ development_branches”创建分支,每个子文件夹一个。2.签出新创建的分支,并使用git filter-branch命令用子目录的内容替换根目录内容

git filter-branch  -f --subdirectory-filter <subdirectory_name> HEAD

So, for the git structure shown in the question, I used the commands below 因此,对于问题中显示的git结构,我使用了以下命令

$ git checkout development_branches
$ git branch d1
$ git branch d2
$ git checkout d1
$ git filter-branch  -f --subdirectory-filter d1 HEAD
$ git checkout d2
$ git filter-branch  -f --subdirectory-filter d2 HEAD
$ git branch -d development_branches

After this the new Git structure is 之后,新的Git结构是

Root
   + b1
   + b2
   + d1
   + d2

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

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