Search code examples
gitsvngit-svn

How to properly initialize git-svn clone of a repository with nonstandard layout?


I am trying to work using git with svn repository that has the following rough layout:

RepositoryHone

  • -> Documents
  • -> ExtraDocuments
  • -> playground
  • -> playground_dev
  • -> playground_balance_change
  • -> Tools

where playground contains main development branch (trunk), and playground_dev, playground_balance_change and others not shown are branches.

In branches, layout goes like this:

  • -> build
  • -> lib
  • -> bin
  • -> src

I mostly wanted to work with playground and playground_dev, so i have run:

git svn init svn::/server.address:port/RepositoryHome -T playground -b playground_dev

git svn fetch

However, when i have run git branch -r to check how branches were imported, i found with my growing horror, that there were, besides "origin/trunk", "branches" like "origin/bin", "origin/lib", " origin/src" and so on.

How can i ensure correct mapping of branches between local working copy/git repository and the server?

Is it possible to fix the situation without fully fetching, as process takes a lot of time (roughly 16 hours)?


Solution

  • The problem can be solved in 2 steps.

    1. First, delete all errroneously-tracked branches.

    2. Add correct branches to repository.

    To delete offending remote references, one can find them with git branch -r, and then remove with git branch -D.

    I haven't found "proper" command-line based solution for second step, but fortunately git-svn documentation, more specifically Configuration section gives enough details to do things by hand.

    Most important thing is, one cannot just set a single branch to track svn remote; in configuration only "branches" key is recognized, which necessitates usage of wildcard substitution.

    So, one can just add another svn remote - by hand, in .git/config, copying one that is already present, changing remote name and value of "fetch" key. That way one can setup a branch that corresponds to a single remote svn branch and work as usual after.