Clone GitHub Repository from Visual Studio

Keeping a track of your changes and their history is very important for a developer. GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.

In this post, we will clone our code from the created repository in GitHub using Visual Studio. Check out my previous post where we saw How to Create GitHub Repository?

Pre-requisites

  1. Visual Studio
  2. GitHub Account

The visual Studio download link can be found on the downloads page.

Clone your Code from GitHub using Visual Studio(VS)

I hope you have the repository ready in GitHub that we can clone it. You may have a similar repo like this as shown below. I will clone a Console Application.

Sample GitHub repository we will clone using Visual Studio (VS)

Open your Visual Studio. On the Home Screen, click on Clone a Repository. I will be working on Visual Studio 2022 Preview. There is no change in the Visual Studio 2019 steps.

Clone a repository in Visual Studio on VS startup

You can clone the repo in two ways –

  1. Clone it using the Repository Link
  2. Clone it using the GitHub option in Visual Studio

Clone GitHub Repository in Visual Studio using Repository Link

Click on Code in the GitHub repository and copy the GitHub repo URI.

copy the GitHub repo URI

In Visual Studio, paste the URL and choose the local directory path where you want to clone the GitHub repository. Click on Clone.

Clone a GitHub repo using the repository URL

That is it. If you see a blue lock symbol against your files and folders, that means you have successfully cloned your GitHub repository from Visual Studio using the Repository link. If you are asked to log in to GitHub from a small pop-up dialog window, log in. This is required for Private GitHub Repos.

Successfully cloned the GitHub repo using the GitHub repository Link

Learn to push back your code changes to GitHub from another post here.

Clone GitHub Repository in Visual Studio using GitHub Option

On Visual Studio Startup, click on Clone a Repository. This time, click on the GitHub option.

Clone GitHub repo using the GitHub inbuilt feature.

If you are cloning from GitHub for the first time in VS, click on Sign in and choose GitHub Account. If you are already logged in to GitHub in your browser, the authentication will be successful automatically.

Sign in to GitHub from Visual Studio

Choose a repository and select the local path where you want to clone. Click on Clone.

Select the GitHub repo and click on Clone

That is it. If you see a blue lock symbol against your files and folders, that means you have successfully cloned your GitHub repository from Visual Studio using the GitHub option.

successfully cloned GitHub repository from Visual Studio using GitHub option

Learn to push back your code changes to GitHub from another post here.

Thank you All!!! Hope you find this useful.


Up ↑

%d bloggers like this: