Esbjerg
Esbjerg

Reputation: 65

Add multiple Projects (from one Solution) to a single Visual Studio Team Services Git repository

I have multiple projects under one solution and I would like to add them to the same Git repo on Visual Studio team services.

For example in the Solution I have:

  1. The main application Project
  2. The admin application Project
  3. A data access logic Project

As the first two projects are totally dependent on the third project I would like to add them to the same repository.

I am using Visual Studio 2015 and Git. These are also MVC, C# projects.

Is it possible to have multiple projects, from the a single Solution, in the same Visual Studio Team Services repository?

If not, I can't seem to upload any of the projects to a different repository (from the same Solution), is this possible?

I would ultimately like to avoid needing to switch solutions while developing.

Upvotes: 4

Views: 14795

Answers (3)

Dumidor Dumbleplex
Dumidor Dumbleplex

Reputation: 111

I had the same problem, TLDR this will work if your projects in that solution are located under one main dir. for example

Drive\ProjectX\Proj1
Drive\ProjectX\Proj2
Drive\ProjectX\Proj3

In my case i had my solution (.sln) and (.git) in Proj1 folder which was synced to my repo.

Then i did this

  1. Add external tool to your visual studio According to this post
  2. Use gitbash tool (CLI) to move (.git) folder on folder up.

mv "Drive\ProjectX\Proj1\.git" "Drive\ProjectX\.git"

  1. Then follow these steps in your bit bash CLI
cd "Drive\ProjectX"
git add .
git commit -a
git push
  1. Then close or reopen your solution in visual studio and you will be able to commit all changes to your repo and it will include all them projects.

Not sure how to do that if you have projects located outside solution folder such as

Drive\ProjectY\Proj4

I'm in no way or shape pro in these things, this is what helped me to get my separate projects to sync with git when i make changes in the whole solution.

Upvotes: 2

Tingting0929
Tingting0929

Reputation: 4192

Yes, it is possible.

  1. Clone a Git repo from VSTS in Visual Studio 2015, and copy your solution with the 3 projects under this repo.
  2. Add the solution to git. You could open the solution using VS 2015 and right click the solution choosing "Add solution to Source Control"
  3. Commit your changes.
  4. Push your repo to VSTS.

Both the above actions you could do it in Visual Studio or using Git command.

Upvotes: 0

Chris Melinn
Chris Melinn

Reputation: 2076

Is it possible to have multiple projects, from the a single Solution, in the same Visual Studio Team Services repository?

Yes, absolutely. A repository (a Git repository, in this case) can contain any set of files & folders that you wish to manage in source control. Think of it essentially as a top level folder / collection.

Normally, yes, you would have the entire solution and child projects in the same repository. If I interpret your question correctly, I think you are just asking how to add the projects into the repository, which is really just git question - just add all your project files/folders into the git repository and commit them.

Based on your question, maybe your git repository (the .git folder on your file system) sits at the level of your project folder? If that's the case, you might be asking basically how to move this up? If that's the case, see similar questions here:

Moving a git repository up one hierarchy level

My Git repository is in the wrong root directory. Can I move it? (../ instead of ./)

Feel free to clarify if I have misunderstood your question.

Upvotes: 5

Related Questions