Set Up GitHub With .NET Project

What is GitHub?

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. 

Why GitHub

It is version control, which provides us a centralized location, where we can publish our working code or project and share it with the other developers. Basically, GitHub is open-source version control for the developers, programmers, and designers, so that they can publish and keep track of the changes when a new version releases for the projects. It is free and can be downloaded from GitHub.

Create Account

First of all, you need to create a GitHub account. Here, you can choose your display name and provide your Email ID to sign up.

Setup GitHub With .Net Project

After click the "Create Account" button you will redirect to another page and that you need to select the proper options and then click on the "Complete Setup" button.

Setup GitHub With .Net Project

On clicking the Complete Setup button you will redirect to a login page and will get a verification email address email for verifying the email address. You need to click on the "Verify email address" button from the email.

Setup GitHub With .Net Project

On click the "Complete Setup" button you will redirect to login page.

Setup GitHub With .Net Project

When you sign in with your credentials, it will show you the profile page on GitHub. Here, you can create a Repository, as given below,

Setup GitHub With .Net Project

After that, we create a new repository for our project. For that click on the "Create a repository" button and you will redirect to a new page which will look like below.

Setup GitHub With .Net Project

Enter the repository name which you want to create in to "Repository Name" field.

There are two options,

  1. Public
  2. Private

If you want to set your repository for the public then you need to select public and if you want to keep it private for you then you need to select the Private option.

After that fill up all fields click on the "Create Repository" button and you will redirecting below the repository page.

Setup GitHub With .Net Project

Add Visual Studio Project in GitHub

Now, it is time to create a project inside Visual Studio and publish it in GitHub. Thus, I have created a dummy project only for demo purposes in Visual Studio 2019. It is a Mvc.net Application and nothing else.

Setup GitHub With .Net Project

Now, right-click on the solution and it will provide an "Add Solution to Source Control" option. You need to click this to add this project to GitHub. As I have said earlier, it is nothing but a source control to add the projects.

Setup GitHub With .Net Project

It will provide a "Choose Source Control" popup, where you can choose Git as source control. Another option is for TFS. For TFS, choose GitHub and click OK.

Setup GitHub With .Net Project

Click on the "Publish to Github" button and then click on Add/Change Accounts.

Setup GitHub With .Net Project

Setup GitHub With .Net Project

Setup GitHub With .Net Project

After login and fill in all data and click on publish button all your project's files are uploaded to a specific repository like below.

Setup GitHub With .Net Project

After all, files are published to GitHub repository, in project display lock icon in front of all files.

You can clearly see that all the published files are locked [Lock sign].

Setup GitHub With .Net Project

If you do any change in any file then display a red icon in front of that file. If you want to commit that code then you need to click below the pencil icon and go to the explorer.

Setup GitHub With .Net Project

Add comment and click on the "Commit All" button to commit code in the local repository.

Setup GitHub With .Net Project

For commit code in global means, GitHub Repository clicks on Sync and pushes the local commit.

Setup GitHub With .Net Project  Setup GitHub With .Net Project

In the repository, you can see total commits, changes, and all code.

Setup GitHub With .Net Project

NOTE: If you are not getting the Git option, please Go to https://visualstudio.github.com/ and download the extension for Visual Studio.

Setup GitHub With .Net Project

Thus, everything is done on GitHub. If you require it anytime from anywhere, you can download it. If you make any changes in the project file which is added to GitHub, click Changes.

Setup GitHub With .Net Project

It will show all the files, which have made any changes. You can just pass the commit message and click to commit to upload these files into the Remote Repository.

Setup GitHub With .Net Project

After clicking Publish, it will be published in your project in the master branch. Master branch is a default branch for GitHub Source Control. You can also create a new one for your requirement.