tags:

views:

438

answers:

2

I have a repository whose layout is like this:

    trunk/
        projectA
        projectB
    branches/
        projectA-1.0
        projectB-1.0
    tags/
        projectA-1.0.1
        projectB-1.0.1

I want to convert them to separate git repositories with the trunk/projectA as the top-level directory and all it's branches as git branches.

Whenever I try to specify a git svn init like git svn init -T trunk/projectA -b branches -t tags http://svn.example.com, the follow-up git svn fetch fails mysteriously on different revisions. Sometimes it gets all the way to 200, sometimes it stops.

My current thinking is that I should create a git repository that mirrors the whole subversion repository as a single entity with subdirectories for each project. Then I would use git-filter-branch to rewrite the subdirectories to the root of the project.

However, I'm not sure how to get the branches to behave like I want using git-filter-branch and.

Also it would be ideal to create a single git repo that has different branches for the "trunk" of each project, I would have no problem not really having a master in this case.

+4  A: 

Did you consider svn2git in order to import your svn into a git repository ?

It is better than git svn clone because if you have this code in svn:

  trunk
    ...
  branches
    1.x
    2.x
  tags
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

git-svn will go through the commit history to build a new git repo.
It will import all branches and tags as remote svn branches, whereas what you really want is git-native local branches and git tag objects.
So after importing this project, you would get:

  $ git branch
  * master
  $ git branch -a
  * master
    1.x
    2.x
    tags/1.0.0
    tags/1.0.1
    tags/1.0.2
    tags/1.1.0
    tags/2.0.0
    trunk
  $ git tag -l
  [ empty ]

After svn2git is done with your project, you'll get this instead:

  $ git branch
  * master
    1.x
    2.x
  $ git tag -l
    1.0.0
    1.0.1
    1.0.2
    1.1.0
    2.0.0

Finally, it makes sure the HEAD of master is the same as the current trunk of the svn repo.

So in your case, it would give you actual git branches to apply git-filter-branch.

VonC
I haven't, that's new to me. I'll investigate. Thanks!
Otto
That didn't actually work. It left out a whole year's worth of commits.
Otto
Strange, it did work just fine with my svn repo...
VonC
As it turns out, it may have been something up with my machine. git svn clone also started to fail for me. Eventually, we were able to clone the thing, though massaged the history a bit differently.
Otto
A: 

What I ended up doing was cloning the root of the repository and copying that new git repo for each project and rearranging things. It wasn't clean or pretty, but it was legacy code that I no longer need to look at very often.

Otto