2

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

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

Works for me - thanks vumaasha! I tried the Ruby Gem svn2git but couldn't get past the "command failed: git checkout –f master" error...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.