Introduction
In this article, we will learn how to upload an existing .NET project with multiple class library folders into a GitHub repository. To put a project up on GitHub, It is required to create a repository first which contains all project files, including the revision history.
Let's follow the steps mentioned below,
Step 1
Login to your GitHub account and go to your repositories to create a new repository.
Step 2
Click on the New option and initialize a short, memorable name for the repository, choosing the visibility, etc. After performing these steps click Create Repository option.
Now the repository has been created successfully and initialized with a README file as shown below,
Step 3
Copy the repository URL from GitHub.
Step 4
Open Visual Studio 2019 and click on the 'Clone a repository' option, which opens a new window and will ask for the repository location and local path to clone it to your local computer which pulls down a full copy of all the repository data that GitHub has at that point in time, including all versions of every file and folder for the project.
Now a copy of the GitHub repository is created on your local computer like below and is visible in Visual Studio Solution Explorer also.
Step 5
Let’s assume that there is an existing .NET Project with 2 class libraries as shown below and we are going to upload this complete project into the GitHub repository.
Step 6
Copy all the folders and files of that project and put them into the newly created local repository. Open Visual Studio and go to the Solution Explorer. You can see a + icon before the files which signify that the item is new will be added to the source control upon the next commit. Now go to the Git Changes option in Visual Studio to see all the changes to your files and folders in the locally cloned repository as mentioned below,
Step 7
Give a comment so that you can keep track of your changes. Now click on the 'Commit All & Push' option. On successfully pushing the changes, your project including other folders will be displayed in the GitHub repository file section as shown below,
Summary
Here we saw how to add an existing .NET project with multiple class library folders into a Github repository using Visual Studio 2019. Hope you enjoyed this article.