Should Git Repo's be at the Solution Level or Project Level in Visual Studio

Visual StudioGit

Visual Studio Problem Overview


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?

Visual Studio Solutions


Solution 1 - Visual Studio

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.

Solution 2 - Visual Studio

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.

Solution 3 - Visual Studio

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

Solution 4 - Visual Studio

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.

Solution 5 - Visual Studio

Some though and 3 solutions on the subject can be read on that blog: https://www.atlassian.com/blog/git/git-and-project-dependencies

  1. package management tool, i.e. nuget in VS, so using reference to a package/compiled module
  2. git submodule (only with command line in VS?)
  3. other build and cross-stack dependency tools

Another solution is just to add a project from the other repo and let it out of the current repo, and latter use the Team Explorer to commit its changes.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncmaduroView Question on Stackoverflow
Solution 1 - Visual StudiobouvardView Answer on Stackoverflow
Solution 2 - Visual StudioCB BaileyView Answer on Stackoverflow
Solution 3 - Visual StudioBryan AlvesView Answer on Stackoverflow
Solution 4 - Visual StudioAlbicView Answer on Stackoverflow
Solution 5 - Visual StudioEricBDevView Answer on Stackoverflow