How to Checkout or Clone Repository from GitHub in Visual Studio 2022

How to Clone or Checkout Private or Public, GitHub repository by using Visual Studio 2022 with git URL for blank or repository with project files.
In today's article I will show you how you can checkout latest code from GitHub using Visual Studio 2022. So, for this first we need to create a repository in the GitHub it can be either private or public and Visual Studio 2022 in your machine. So first we will create a local folder in your machine.  After creating the folder, we need to create a new repository in GitHub. Your repository will look as shown below.

https://github.com/git-account-user-name/demorepo

Now copy the path and open Visual Studio 2022. After opening the Visual Studio 2022 check the left side menu panel names as "Get Started".
Clone a repository in Visual Studio 2022
Click on "Clone a repository" you will get the below screen shot.

Clone github repository in local path by visual studio 2022
Now click on "Clone" button. If you get popup for entering User Id and Password, you need to enter the detail and click on login. Ones you were done by adding credential visual studio will open and start downloading the file from repository. 

Download file form Git Repository

Now here are having two scenarios first we are checking out a blank repository and the second one is your repository is already having the source code of a project. Now let's first cover a blank repository. In case of blank repository in checkout folder we will get a folder .git and .vs.

Empty repository

Blank Repository

For this close the Visual Studio 2022. After closing the Visual Studio 2022 reopen it and create a new project in the local repository folder or any of the location which you like. 

Demo project

Now copy the file in the repository folder, and after open the project by clicking on .sln file. By default, the repository will be selected. 

Selected Repository

Now open the Git Changes panel and we need to stage all the files by right clicking on the project folder or the file which you want to commit. After staging the files, we need to add the comment and click on commit stage. After committing the stage, we need to push the changes to repository by clicking on Push button.

Push to Git

Now we are done open your repository in GitHub.com and check your files.

GitHub file in repository

Repository Having Files

When we checkout a repository already having files, after cloning the repository you need close the visual studio and go the local folder where your code files are available. Open the project you will get repository selected by default and your Git Changes panel will be blank. It will show only those files in which you have you have made the changes. 

To commit the code stage the file in which you are having change. After staging the file click on commit stage. Ones commit is completed you need to push the files to repository.

Post a Comment