user4187589
user4187589

Reputation:

Split SVN repository into several Git repositories

I have a SVN repository with this file structure:

    |---trunk
    |   |---project1
    |   |---project2
    |   |---project3
    |
    |--branches
    |   |---1.1
    |       |---project1
    |       |---project2
    |       |---project3
    |   |---1.2
    |       |---project1
    |       |---project2
    |       |---project3
    |--tags
    |   |---1.1
    |       |---project1
    |       |---project2
    |       |---project3
    |   |---1.2
    |       |---project1
    |       |---project2
    |       |---project3

I would like to migrate everything to Git (keeping history), so that afterwards I have 3 git projects: project1, project2, and project3.

In order to do that, I was thinking that it would be a good idea to create a new repository for each project and then migrate each repository to Git.

I searched online but I cannot find a solution for this file structure. Should I use SVN filters or what? (I don't know much about SVN).

Upvotes: 4

Views: 1896

Answers (1)

sleske
sleske

Reputation: 83635

While splitting the repository with SVN is possible, it will be much easier to do this with git, which is much more flexible when it comes to rewriting and reorganizing history. If you still insist, see below :-).

So my recommendation is:

  • Either: Convert the repo to git first, then split it. For the splitting, see e.g. the question Split large Git repository into many smaller ones (which incidentally also describes a migration from SVN).
  • Or: Convert and split in one go, by converting the repo piece by piece. When converting to git, you can tell git only import/convert one SVN folder (with history and subfolders). That way, you create a git repository for the parts of the SVN repository right away.

If you have to do the splitting with Subversion, the only realistic option I see is to use svnadmin dump and svndumpfilter.

Basically, you will dump the whole repository to a file (requires admin access to the SVN server), then modify that dump file and create new SVN repos from it. The splitting is explained (for example) in the book "Version Control with Subversion", chapter Repository Maintenance - especially subsection "Filtering Repository History".

For a detailed explanation of a split + migration, see for example Migrating Subversion Repositories to Git – The definitive Guide for TeamForge Users by CollabNet (ironically, the company that founded the Subversion project).

Upvotes: 3

Related Questions