tags:

views:

385

answers:

2

I have got a central SVN repository I must commit to, but I've got a passion for git (like any other developer I know). The case is well known.

Then I read about git-svn and gave it a try. Since I don't need the full history, just from two months or so, I did like this:

git svn clone -r 34000 -s https://svn.ourdomain.com/svn/repos/Project/SubProject

SubProject had, as usual, the subdirectories trunk, tags and branches. Great.

Then, in order to get the last revision, I did

git svn rebase

Some downloads later, great. Last revision, logs, etc. Ok, now I'll switch to my feature branch.

$ git branch
* master

$ git branch -r
trunk

$ git branch -a
* master
remotes/trunk

The questions are: Where are my branches? Have I done something wrong? How should I do in order to get my branches in the new git repo?

git-svn, wherever I have read about it, dealt wisely with branches and tags, but the behaviour is not what I expected. Thanks!

EDIT: I have just found out that git svn fetch will do it. But it will get all revisions, which is something I wouldn't like...

A: 

If you want to see your branches when doing a git branch after a import from svn, you should use the ruby script svn2git (and git2svn)

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
VonC
But doing like this don't I kill every possibility of commiting to the svn repo?Also, my question was not that. I haven't got my branches. So it's not a matter of code organization.
Luís Guilherme
+2  A: 

You say that you haven't gotten your branches in your checkout.

This is likely a problem with the layout of your svn repo.

The 'standard layout' is:

branches/

tags/

trunk/

If you have your layout like this:

branches/user1/

branches/user2/

Then, you will lose your branches when you do git svn fetch / clone.

To fix this, you should give the argument

--branches=branches/*/* to git clone.

rmk