Question

I am migrating a SVN repository to Git.

The svn structure is like shown below

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.

When I use svn2git, to convert this in to a git repository. The folder development_branches is considered a single branch. Below is the Git branch structure using svn2git

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?

Thanks in advance

Was it helpful?

Solution

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

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

So, for the git structure shown in the question, I used the commands below

$ 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

Root
   + b1
   + b2
   + d1
   + d2
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top