Share via


Adding existing projects to an existing solution hosted on GitHub

I have written number of articles about configuring GitHub and deploying some code to it.  Here is a list of them just in case you want to get some perspectives and better know where I am coming from.

As I was creating another repository on GitHub I was having a problem adding existing projects to my local Git solution and then getting them deployed with the correct title.  Here is my story.

As seen in Figure 1, I started by simply creating a repository on GitHub.

image

Figure 1, create a GitHub repository

That worked no problem.  I noticed that the Description in Figure 1 was also the title of the repository on the main page of my GitHub repository here and shown in Figure 2.

image

Figure 2, create a GitHub repository

I committed my initial solution to the local Git and entered a commit message as seen in Figure 3.

image

Figure 3, create a GitHub repository

There was another window that asked for another commit message, like Figure 9 here, so I am not sure where this message actually goes on GitHub, but it worked out that I got the title in the place I wanted it, Figure 4, without messing anything up that already existed.  Wait, nothing else existed at this point.  Just take my word for it, it didn’t mess anything up, I’m actually writing this after having already done this from start to finish.

image

Figure 4, create a GitHub repository

Here is where I got the problem.  When I added a new project to the solution I had deployed to GitHub they were not added to my local Git repo and so I couldn’t get them committed to my GitHub repo.  Here is the trick, real simple, copy the solution to the repo on your machine and add it from there.  I.e. copy the project/solution to the Local Path, see Figure 1 and add it from there.

The project must be in the repo that was created via Figure 1.  At least when I tried adding a project that was not in that directory it would not add to the source code repository.  Only after copying it into the source\repo directory, it worked and I could then deploy it out to GitHub.

Then, I created a ‘New Solution Folder’ and added the projects into that folder as needed, see Figure 5.

image

Figure 5, add existing project / solution to a GitHub repository

Then, once I added all the projects to the ‘New Solution Folder’ as seen in Figure 6.

image

Figure 6, add existing project / solution to a GitHub repository

I committed all my changes to the local Git, as seen in Figure 7.

image

Figure 7, add existing project / solution to a GitHub repository

Then I Sync’ed and Pushed my changes to GitHub as seen in Figure 9 and Figure 10 in this article and in the below Figure 8.

image

Figure 8, add existing project / solution to a GitHub repository

Then the projects went to my GitHub with the titles I wanted and I was a happy camper, Figure 9.

*NOTE: I found that if there is only 1 project within a ‘New Solution Folder’ that VS or GitHub changes the form of the rendering.  So I added a second dummy project just to make it look pretty.

image

Figure 9, add existing project / solution to a GitHub repository

This is cool stuff indeed.

I searched for some reasons of my existing projects not being added to my local Git or GitHub and couldn’t find ‘my reason’ so I write this in hopes it will help someone else some day.  If it does, let me know.