How to create a git clone with branches of a “subproject”?

Here’s the situation: We’ve got a huge svn repository, which is the “master” (can’t change this because it’s actually “owned” by another company). We would prefer to work locally in git to get the branching flexibility and speed that git offers. But we don’t want to clone the whole repository.

The repository structure looks roughly like this:

  • How to git diff all changes since branching from master?
  • How to change folder with git bash?
  • missing changes in commits in git
  • Finding the first commit on a branch with GitPython
  • Git: how to use rebase with theirs strategy
  • How can I make git do the “did you mean” suggestion?
  • /trunk/project1/*
          /project2/*
    /branches/branch/project1/*
                    /project2/*
    /tags/tag1/tag1a/project1/*
              /tag1b/project1/*
         /tag2/tag2a/project2/*
    

    I’m only interested in project1, but I would like to have both trunk and branches (tags are not so important, but it would be nice to get them, too).

    I’m able to get a single branch cloned with these svn-remote settings:

    [svn-remote "svn"]
        url = https://svn.company.com/svn/branches/branch1/project1
    

    but I really want to get the branching structure, too. I have thought about using ignore-paths:

    [svn-remote "svn"]
        ignore-paths=^project2|^project3|...
    

    but I would have to update the ignore-paths every time a new top-level “project” directory is added, which is not really sustainable.

    Secondarily, we really need only the tags in /tags/tag1 (if we need tags at all). Any thoughts on how to do that would be appreciated.

  • Git how to detect whole folder deleted/moved
  • How can I display commit's position in the history relative to tags (and branches)?
  • Trying to find a good strategy using Git for personal development on local/personal machine
  • Capistrano still trying to connect to my old repo
  • Automatically skip empty commits when using git rebase
  • git word-diff-regex that works with multiline changes?
  • One Solution collect form web for “How to create a git clone with branches of a “subproject”?”

    I think that the following in your .git/config file should work:

    [svn-remote "svn"]
      url = https://svn.company.com/svn
      trunk = trunk/project1:refs/remotes/svn/trunk
      tags = tags/*/project1:refs/remotes/svn/tags/*
      branches = branches/*/project1:refs/remotes/svn/branches/*
    

    I based this on the configuration section of the git-svn manpage

    Git Baby is a git and github fan, let's start git clone.