I am working (alone) on an application that is a music portal where you can search for artists, songs etc …
The C# solution consists of:
- a class library that contains all the stuff to access the web service
- the application itself
I’ve recently started using Git and figured out the benefits it does provide to a project but there’s something I couldn’t figure out, on Visual Studio there is the option to commit a solution which leads me to the following question :
Should I commit each project individually or the whole solution ?
A Visual Studio solution is a whole entity. The source control providers work on the solution level. The solution is something that you can compile in itself, for a single project it may not be the case. There can be commits when you need to touch multiple projects at once so that the solution compiles after each atomic commit (especially in your case where there is a breaking change between the two layers). So I’d say it should be the one that you commit.
Although, your project (in a human sense, not VS sense) doesn’t have to consist of a single solution. It is not uncommon that you develop a library that can be used by anyone, and you want to publish that as one product in itself. And you also develop an application which uses that library, and publish that as a separate product. From the aspect of the application, your library is not part of the solution, it is an external 3rd party library.
1
I run in the same question as yours and here is my way to apply git:
-
for each project folder inside the solution folder, I initialize the git repository.
-
for the solution folder, I also initialize the git repository and add project folders into the .gitignore file of the solution repository.
Although I have commit each project and the whole outside solution individually but I have opportunity to deploy each project in its own edition (UAT, Production, …).
P.S: I use Git-Bash instead of the Git features of the Visual Studio.
1