Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

All Branches in a Single Directory

This layout is probably the simplest possible case to map since there's only one single directory, with no branches or tags or any nested directories that can make the mapping more complex. Actually, this approach can apply to several different layouts: it can be some relatively simple SVN repository that has no branches or tags and all the files live right in repository's rootThe next common SVN projects layout is, in fact, no layout: all the SVN directories - branches, tags and all - just lay in project's root or inside its subdirectories, not following any placement conventions or certain layouts. Having such a layout it's a good idea to follow some naming convention at least, but generally, directories names don't follow any conventions either. So the SVN project might look like this:

/bug_1224           # branch

In this case, all that is needed to translate the project into Git is to set svn.url to point to SVN repository's root directory:

And all the trunk, branches, tags and shelves setting in SubGit's configuration file can be either commented:

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

or just removed.

Note, that in such case (repository root is used) it's impossible to add branches or tags later on.

The same approach applies to the case when all the files reside in project's (not repository) root directory: that is, each project in repository has its own directory, but the project being translated has no branches and tags and all the files are situated right in project's root:

/issue1678          # branch
            /features           # second level directory
                /project_1f4536          # branch
    /feat 4589      # file2branch
            /main               # "main line" fileN
v.1.5.6_b3345      # some tag (snapshot)
            /1.5.7 build 7890   # some  /project_N

Similarly, we can just set svn.url to point to project root:

and comment the mapping settings:

#trunk = trunktag (snapshot)

SubGit can handle such SVN layout, but it could be quite effortful to create correct mapping scheme to mirror SVN project of that design. If the directories placement doesn't follow any layout and directories names don't follow any conventions, then the only way to map each and every SVN entity to Git counterpart is to create excplicit mapping for every directory. Thus for the Project)N above the mapping scheme can be set like this:

trunk = main:refs/heads/master
    #branchesbranches = branches/*bug_1224:refs/heads/*bug_1224
    #tagsbranches = tags/*issue1678:refs/tagsheads/*issue1678
    #shelvesbranches = shelvesfeatures/*f4536:refs/shelves/*

or remove them at all.

Unlike the first case though, the mapping for this layout can be set in one more way: we can set the svn.url to point the repository root directory:

and set project directory to be trunk:

trunk = project_1heads/f4536
    branches = features/feat 4589:refs/heads/masterfeat 4589
    #branchestags = branches/*v.1.5.6_b3345:refs/heads/*tags/v.1.5.6_b3345
    #tagstags = tags/* 1.5.7 build 7890:refs/tags/*
    #shelves = shelves/*:refs/shelves/*

This approach will also translate the project to Git; but additionally, branches and tags can be created and added to translation later with almost no configuration effort since project's directory acts as a trunk.

One more common case is that only one particular branch has to be translated to Git. The repository and project can be arbitrary complex, e.g.:

1.5.7 build 7890

The svn.url must point to the Project_N root, so it must be set as:

url =

Of course, it might be rather laborious to create an explicit mapping for big projects - but unfortunately, it's the only way if no conventions followed. If, say, directories name do follow certain convention (or just have some similarities, even occasional), then wildcard can be used to map a bunch of branches (or tags) together and it can make the mapping process much easier. Suppose, the branches names follow name patterns "bugxxxx", "issuexxxx" or "fxxxx", and all the tags called like "v.x.x.xxxxx" or "snapshotxxxx", i.e. the Project_N layout looks like this:

            /projectbug_1224           #branch
            /trunkbug_2379           #branch
bug_2471           #branch
issue_1678         #branch
            /issue_1890         /bugs#branch
            /issue_2021         #branch
            /features           #second level directory
                /f4536          #branch
 /f4589          #branch
                /f4602          #branch
main               #"main line" (trunk)
v.1.5.6_b3345      #some tag (snapshot)

but if only branch_1 needs to be translated - it can be done as simply as

url =

/v.1.5.7_b7890      #some tag (snapshot)
          trunk = branch_1:refs/heads/master
/snapshot_3329      #some tag (snapshot)
          #branches = branches/*:refs/heads/*
    #tags = tags/*:refs/tags/*/snapshot_3431      #some tag (snapshot)

then the mapping can be set like this:

trunk = main:refs/heads/master
    #shelvesbranches = shelves/bug_*:refs/shelvesheads/*

that is, we set svn.url to point to the branches directory inside the project directory and set branch_1 to be trunk.

Another way is to set svn.url to point directly to the branch_1 directory:

url =

and comment (or remove) all the rest options:

#trunk = trunkbug_*
    branches = issue_*:refs/heads/masterissue_*
    #branchesbranches = branchesfeatures/f*:refs/heads/f*
    #tagstags = tags/v.*:refs/tags/v.*
    #shelvestags = shelves/snapshot_*:refs/shelvestags/snapshot_*


This will mirror all the present SVN branches and tags to Git repository.

Another approach to mirror such unordered layout and to make it ordered: that is, change the project layout so that the project follows some convention - e.g. SVN recommended layout. It can bring many advantages even besides SubGit mirroring facilitation, though such a relayout can be very hard. And additionally, such SVN project relayout brings some peculiarity to SubGit mirroring as well, it's described in the next section.