tags:

views:

459

answers:

5

Hi, we use SVN for our work. We are a small webdesigner studio and we write in PHP developing some kind of "framework" meantime.

Now we are thinking about some more powerful solution and we would like to try git-svn. We use branches as different projects - one branch, one project. So I have in my computer exactly the same structure in my wwwroot. One branch = one project = one virtualhost.

As I played with git-svn I don't know how to achieve this with it. I need the branches to be physically present in the filesystem because I have virtulhosts in Apache etc.

Can you please give me some advice or point me to some tutorial how to do it?

Thank you very much

+3  A: 

You're doing it wrong™.

Seriously, branches are meant for, well, branches. You should use different repositories for different projects.

If I'm getting this right, you have a single framework you're working on, and several projects based on that framework. No matter what revision control system you use, that translates to one repository for the framework, and one repository for each project.

This is the reason git shows you only one branch at a time in your working copy. You usually work on a single branch at a time. You need one working copy per branch if you need to have working copies of all branches.

Can Berk Güder
Depends. You can have repo:/tags,/branches,/trunk per project or you can have repo:/project1/tags,project2/tags, etc.. depends on your needs.
Marcin Gil
@Marcin: yes, but apparently they have repo:/branches/project1, repo:/branches/project2. and in git, you can't have repo:/project1/branches and repo:/project2/branches.
Can Berk Güder
well, we have a trunk as a "stable" framework copy, each website is in its own branch - when we add something we need in a framework, we merge it to trunk
Petr Svoboda
A: 

You can do similar thing with Git itself - see Git submodules.

In this way you have a Git repo for whole "wwwroot" and submodules for each project. If your working only on a few projects of all you can check them out/clone separately.

I have never found git-svn to be a good solution. I either use SVN or Git, not both.

Marcin Gil
maybe it is the solution, but will I be able to get my changes back to SVN? I thought I will use git for merging and svn for other developers for their ease of use
Petr Svoboda
I'm using svn as main repo and have my personal git repo inside it; but it invalidates all of advantages of git. IMVHO if you use SVN and don't want to switch to Git completely - drop the idea of using it. Test it for small subset of projects and decide.
Marcin Gil
A: 

Having just switched from svn to Git myself, I'd agree with the two answers above.

I'd also recommend against using git-svn (except perhaps to import your existing svn repositories into Git, as a once-off one-way event). And I'd also recommend using a separate Git repository for each project.

With svn, some people like to use a single repository because it's easier to share code between projects, etc. With Git, you're better using a single additional repository for all your shared stuff; if something starts out in one project and you later want to share it, do a subtree merge (that's a specifically-documented Git term, by the way) into your shared repository. Then you can pull the code back to your other projects.

Calrion
A: 

As others have said, use separate repositories, not branches.

With SVN, you could just have..

http://svn/site_a/trunk/
http://svn/site_b/trunk/
etc

Then you can svn co http://svn/site_a/trunk/ each site separately

With git, you would just create multiple repositories:

mkdir site_a
cd site_a
git init
cd ../
mkdir site_b
cd site_b
git init

You could have a "master" repository with each site added as a sub-module, but this is not what git-submodule is intended for, and I found it more trouble than it's worth.

It's not a very good idea to use git-svn for anything more than migrating an SVN repo to git, or working on a project you don't control.

If you want to use gits branching (and it's other benefits), why not switch entirely to git? You can set it up in a somewhat-SVN-like centralised-fashion, using something like gitosis

Basically, if you like git, switch to it (rather than using git-svn). If you are looking at git just for the branching, do not - split your SVN repository into smaller projects (site_a/trunk/ and so on)

dbr
@dbr: I cannot switch to git. Some of my co-workers are happy with SVN because they don't merge ;-). Would it be reasonable to do git clone instead of git init in your example? Then I could have my structure. What would you think?
Petr Svoboda
Absolutely, git init just creates a blank repo, git clone would create a blank repo then pull the changes into it.
dbr
A: 

So the time has shown us the best solution ;-) We switched to git completely with new major version of our framework. So the projects based on an older version are still maintained through SVN repository and the new development is running in git. Thank you all for help!

Petr Svoboda