tags:

views:

59

answers:

1

Hi guys, I'm doing an internship and they are using SVN (although there has been some discussion of moving to hg or git but that's not in the immediate future). I like git so I would like to use git-svn to interact with the svn repository and be able to do local commits and branches and stuff like that (rebasing before committing to svn of course). However, there is one slight wrinkle, the svn repository layout is a little weird. It basically looks like this

/FOO
  +-branches
  +-tags
  +-trunk
    +-FOO
    +-myproject

Basically, my project has been stuck into a subdirectory of trunk, and there is another project that is also a subdirectory of the trunk. If I use git-svn and only clone the directory for my project instead of the root, will it get confused or cause any problems? I just wonder because the commit numbers are incremented for the entire repository and not just my project, so would commits be off or anything like that? I probably wouldn't push any branches or tags to SVN because I'd prefer to just do those locally in git and I don't know how git-svn deals with branches and tags anyway, and no one else uses them so I find little point in doing so. Thanks for the help!

+1  A: 

I use git-svn in a multi-project multi-platform svn repo.

I usually just have the local git repo point directly at the svn repo directory that I'm interested in, and forego any native support for branches and so forth, though I hear good things about the support getting better. There seems to be git svn branch support in the git-core documentation.

The way I do it:

git svn init http://repo.farts.com/svn/path/to/the/directory/of/project
git svn fetch

And when its time to commit...

git stash
git svn rebase
git stash pop
git commit -am "Some really awesome stuff"
git svn dcommit

I've had no trouble with this. Popping the stash kicks off a merge if there have been changes to the code that you've rebased onto. Rebase keeps the history linear. There may be a better way to do this, but I've survived, with the above process plus git mergetool.

You can also look at the custom layout options that come with git svn for designating where trunk, branches, and tags are in relation to each other. You can specify each of these separately with -T trunk -b branches -t tags -- these are relative by default, but you can supply absolute paths.

Also, as a word of advice, I would personally just use the SVN client depending on the sensitivity of the internship. I'm not being a member of good citizen of git-town by saying this, but source control can be a major pain in the ass, and also holy ground to people -- if it causes a single ounce of inconvenience to anyone, its almost not worth it. That being said, if you can stay independent and not burden anyone with your tool choices, happy git'ing ;-)

Josh

Josh
Hmm, that seems like what I want to do. The only reason I asked this was because in the pro git book section on git-svn, he says something about how svn will let you commit if commits occurred in between your last push and your current one as long as you didn't touch any modified files, but git gets confused by this, so I thought maybe it would cause problems if I only checked out a subdirectory. It seems like you're doing fine though.I don't think they really care about me using git; my mentor actually said he might want me to explain git because they might want to move to a DVCS eventually
Ibrahim