How do I import svn branches rooted in different directories into git using git-svn?

StackOverflow https://stackoverflow.com/questions/258590

  •  06-07-2019
  •  | 
  •  

Question

I have an SVN repository structure like below. We are using multiple levels under branches for various release maintenance branches, plus a directory for feature branches.

git-svn init seems to work with a single --branches argument, i.e. it seems to expect all of the branches to be in a single location.

trunk
branches
  1.1
    1.2.1
    1.2.2
  1.2
    1.2.1
    1.2.2
    1.2.3
  features
    feature1
    feature2

Any ideas on how to handle this?

Thanks

Was it helpful?

Solution

In your config file, set the svn-remotes section to something like:

[svn-remote "svn"]
    url = svn://svnserver/repo
    fetch = trunk:refs/remotes/trunk
    branches = branches/*/*:refs/remotes/*
    tags = tags/*:refs/remotes/tags/*

This should let you grab the nested branches.

OTHER TIPS

By convention, Subversion branches all live in a single 'branches' path in the Subversion repository, so I'm not surprised that git-svn makes this assumption.

I'd suggest the following (note, you may lose some history in this operation):

  1. Flatten the Subversion branches paths, using a naming convention to keep unique identities and the idea of the current structure.
  2. Perform git-svn
  3. Move things around in the git repository to conform with your practices.

The danger of losing history depends on how well git-svn follows copy operations from dissimilar paths. I've run into this problem migrating subversion repositories (1.4-ish) recently.

Would it be feasible to create a git repo for each of the branch subdirectories?

You could add multiple git svn remotes for each of the branches, or possibly each of the directories of branches. The initial git svn fetch would take forever, but from what I understand it should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top