How To Use Github In Visual Studio 2022

Introduction

We have many ways by which we can manage Github to upload our source code. But Visual Studio provides us a simple and quick way to manage Github directly. We do not need to use any command window like Command Prompt and GitBash to manage our Github repo.

In this article, I will describe the below-mentioned points in detail.

  1. What is Github
  2. Connect Visual Studio 2022 with Github
  3. Create a Github Repo in Public Mode and Push Project
  4. Push Project Changes to Github

Prerequisites

  1. Visual Studio 2022 is installed on your machine.
  2. Basic knowledge of Github commands.
  3. A working project to upload.

What is Github

Github is an online software community platform to collaborate, track, and store a software project. We can upload and publish our software project on Github in both public and private modes. To read more about Github please refer to the article Git And Github Version Control.

Connect Visual Studio 2022 with Github

First, Open Visual Studio 2022 and Open Folder as shown below

OpenProjectImage

Now, click on the "Add to Source Control" as shown below

Add Github Image

Select the "Git" option and you will see the below-given window.

Git Details Account Image

Now you need to fill in the following details.

  1. Add your Github Account
  2. Fill in your Github Owner username
  3. Give the Repository name according to your need
  4. Fill in the Description input

As shown in the below image.

Git Details Account Image

You need to uncheck the Private repository option if you want to make your repository public and click on Create and Push. Now to confirm whether the repo is created or not go to your Github account in the browser and you will find a repo over there as given in the below image.

New Repo Image

Push Project Changes To Github

If we made any further changes to our project we can commit and push those changes to Github from the Visual Studio itself. To check all changes you have made in the project visit the option given in the image below.

Check Changes In Project

Below the Changes option, you can see that we have made changes to one Program. cs file. Now we need to do the following steps.

Add the changes to the staged area 

To add all the changes in the staged area click on the plus icon as given in the below image.

Add Changes to stage area

Commit All the changes with a proper message

To commit all the changes, click on the option given in the below image.

Commit All the Stages Changes

Now Push all the changes in the Repository.

To push all the changes click on the option given in the below image.

Push Changes Image

Now to confirm again go to your Github account in the browser and check all the commits.

Output

In the below image you can see a commit message in the Github account.

Confirm Pushed Changes Image

Article in a Nutshell

  • Add your Github account to the Visual Studio and give the repo name
  • Click on the Create and Push.
  • To push all the changes first add them to the staged area, commit them and then click on the up arrow to push them.

Conclusion

To use Github is a very simple task now. We do not need to learn all the commands like the old way. First, we need to add our Github account in the Visual Studio and then we have a create a repository with the proper name according to our needs. Now click on the Create and Push the button and Visual Studio automatically pushed all the files in the Github repository. Further, if you make any changes to the project you can easily commit and push them directly from the Visual Studio.

Thank You and Stay Tuned for More

Popular Articles About Github

More Articles from my account


Similar Articles