Unconventional repo structure migration

So here is the structure:

  • svn server
    • project1
      • folder1
        • file1
        • file2

If I just run subgit without the trunk command line parameter, nothing gets converted. So I need to provide trunk. But what should trunk be? If I do --trunk folder1 my repo will look like this:

  • file1
  • file2

but I want the files to be in folder1.
So I thought maybe --trunk / or --trunk * or something would work, but nothing does. Any idea what would work? I want the resulting repo to look like this (project deps paths and other reasons):

  • git server
    • repository
      • folder1
        • file1
        • file2

but whatever I do with the --trunk parameter, I can’t get the folder1 created in the converted git repo.


Hello Andrzej,

talking about trunk command line parameter you mean the ‘subgit configure’ command, right? If so, a possible approach is to use another layout with this command:

subgit configure --layout directory https://svn_server/project1 /path/to/subgit/repository

(I set https prior in the URL just for example, it can be any other protocol here ,of course)
This option – layout directory – will set trunk setting to point directly to project1:

trunk = :refs/heads/master

and thus the resulting structure in Git will be exactly that you mentioned. There’s a drawback of this approach, however, it does not allow adding branches in the mapping configuration and cannot be changed without complete repository rebuild.

Another possible approach is to set trunk to point to the project1 and the SVN URL to the server root:

subgit configure --layout auto --trunk project1 https://svn_server /path/to/subgit/repository

In this case, master branch in git will contain the folder1 as it’s intended; but it’s not completely clear what will be set as branches and tags in the configuration as with the layout auto option SubGit connects to the SVN server during the configuration, scans its history and creates a mapping configuration based on the history. So it probably will worth to check the configuration and edit it manually prior the initial import start.
Or just rung the following configuration command:

subgit configure --layout std https://svn_server /path/to/subgit/repository

This command will create so-called “standard” mapping configuration that reflects “standard” SVN repository layout:

trunk = trunk:refs/heads/master
branches = branches/*:refs/heads/*
tags = tags/*:refs/tags/*

Then open the REPO/subgit/config file in a text editor (REPO here stands for the SubGit repository directory) and edit mapping configuration removing branches and tags and setting trunk to point to project1:

trunk = project1:refs/heads/master

Save the file and then run the initial import.

Hi Ildar, thanks for the response! No no I don’t use subgit configure. I just use subgit import command, which has the --trunk and --branch switches. Can I make it work with that?

Hello Andrzej,

I think, it would be better to use the configure command in conjunction with import then; it is the approach described here:

TMate SubGit: Import Book

This approach is more flexible than single import command approach and it provides all the means of the configuration.