views:

340

answers:

4

If I have a C# solution with multiple projects in it, what would be better, to have the Git repo created in the solution folder, or in each individual project folder? Multiple developers will be working on the projects. What are your experiences with this?

A: 

I assume that your solution represents some kind of a product while the projects are just a part of the product.

In this situation I would create the repository on the solution level. This way it is a lot easier to build the whole product at once, especially if the projects depend on each other.

Albic
A: 

It depends. git repositories are most suited to containing a single configuration item with it's own independent lifecycle. If your projects have there own release cycle and are shared between multiple solutions then it might make sense to have them in their own repositories. Usually, though, it is the solution that represents a configuration item with all the constituent projects forming part of the same build. In this case a single git repository at the solution level makes more sense.

Charles Bailey
+1  A: 

I use several (sometimes over-lapping) solutions to contain a collection of related independent applications and shared libraries. As others have mentioned, you really don't want to have a single Git repository containing the source for multiple, independent projects as it makes it much too difficult to track isolated changes.

So, if your solution is structured as mine is then you will definitely want individual Git repositories for each project. This has worked well for me for ten to twelve applications and doesn't create as much maintenance overhead as you might think.

If your solution is truly monolithic (and your sure you want it that way forever and ever), then it probably makes sense to only have a single repository.

bouvard
The problem is if I have an application that needs to be compiled, which is really a solution with multiple projects, and i have 1 git repo per project, how am I going to build the solution easily, without having to pull all the projects and include them in a new solution locally?
cmaduro
Hmmm, I'm not sure I follow. Having one project per repository doesn't prevent you from having an over-arching solution file that includes all those projects and all there build data. (I certainly do, in fact, I have a few like that.) If you are concerned about that build metadata not being version controlled with the rest of the source, you could always wrap around Git repo around just those "solution level" files, although in my case I have found that sort of versioning is overkill/unnecessary. I would be interested to hear any further thoughts you have on the issue.
bouvard
*wrap _another_ Git repo around... (stupid typos)
bouvard
@cmaduro: Perhaps git submodules would solve your problem (see also GitSubmodules on Git Wiki)
Jakub Narębski
I considered this for my projects, but I found that conforming Git's notion of "submodules" to a Visual Studio solutions's expected file structure was non-trivial. (Though not impossible to overcome by any means.) Also, the submodule commands are, to my mind, rather unintuitive and adding the complexity just wasn't necessary for my project. However, your right to point out that if cmaduro's projects have greater needs, this certainly could be a possible solution.
bouvard
I think we are going with the single solution model from patters and practices, and 1 repo per solution. Our class libraries will be added as external references, instead of projects, they will thus have to be built separately. Any thoughts on this?
cmaduro
Well, in general I think its wise to take advantage of the fully-automated build cycle that Visual Studio offers. However, if you can segment your dependencies this way and not put undue burden on yourself at compile time then sure, that seems like it would be alright. This probably does require that the external libraries you depend on are at least _somewhat_ stable. Otherwise you may end up habitually running multiple instances of VS.
bouvard
A: 

git submodule is probably worth consideration here. Each project gets it's own repo, the solution gets a repo, and the projects are submodules.

Bryan Alves