Git – git-svn clone an svn repo with multiple standard directory layouts

gitgit-svnsvn

I have an SVN repo with a layout like
project1/trunk
project1/branches
project1/tags
project2/trunk
project2/branches
project2/tags
etc.

For a number of reasons, I'd like a git-svn repo that allows me to work on any of these projects and fetch/dcommit from/to all of them at once. Is this kind of thing possible? I know I could just git-svn clone the whole thing without specifying branches, tags, and trunk, but then I'd lose a lot of the advantage of using git.

Best Answer

This is how I did it. There may be simpler ways, though.

  1. Select the first project with the standard layout you'd like to work on and git svn clone it:

    git svn clone --stdlayout http://sample.com/svn/repository-name/project-name repository-name

  2. Go into the repository-name directory and edit its .git/config file. You could also do this with git-config commands, but I find it easier in a text editor.

  3. You'll see an [svn-remote "svn"] section already defined for your first project. Rename the svn-remote to something more unique than "svn", probably the same as your project name. E.g., [svn-remote "project-name"].

  4. Make more [svn-remote "project-name"] sections for each project, following the template of the first one. Give each one a unique name! You'll need to change the fetch, branches, and tags settings to use the correct Subversion directory names for each project.

  5. Once you're done, save your file and run git svn fetch --fetch-all. The other projects will be fetched as remotes in your local repository.

  6. To switch your master between projects, do a git reset --hard other-project-name/trunk, just like if you were switching to work on any other remote Subversion branch.