Share via


Clone a Git repository in Visual Studio

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

Visual Studio makes it easy to clone a repository right from the IDE. You can work remotely with the Git provider of your choice, such as GitHub or Azure DevOps.

Prerequisites

To follow this article, you'll need:

Clone a GitHub repo and sign in

  1. Open Visual Studio.

  2. From the Git menu, select Clone Repository.

    Screenshot of the Clone Repository option from the Git menu in Visual Studio.

    Note

    If you haven't interacted with the Git menu before, you might see Clone instead of Clone Repository. If so, select Clone.

    And, if Git isn't on the menu bar, go to Tools > Options > Source Control > Plug-in Selection, and then select Git from the Current source control plug-in dropdown list.

  3. In the Clone a repository window, under the Enter a Git repository URL section, add your repo info in the Repository location box.

    Next, in the Path section, you can choose to accept the default path to your local source files, or you can browse to a different location.

    Then, in the Browse a repository section, select GitHub.

    Screenshot of the Clone a Repository dialog box with GitHub highlighted.

  4. In the Open from GitHub window, you can either verify your GitHub account information or you can add it. To do so, select Sign in from the drop-down menu.

    Screenshot of the Sign in drop-down section of the Open from GitHub window.

    If you're signing in to GitHub from Visual Studio for the first time, an Authorize Visual Studio notice appears. Choose the options you want, and then select Authorize github.

    Screenshot of the authorization dialog box.

    Next, you'll see an authorization confirmation window. Enter your password, and then select Confirm password.

    Screenshot of the confirm access dialog box.

    After you link your GitHub account with Visual Studio, a Success notification appears.

    Screenshot of the Success notification you receive after you link your GitHub account with Visual Studio.

  5. After you sign in, Visual Studio returns to the Clone a repository dialog, where the Open from GitHub window lists all the repositories that you have access to. Select the one you want, and then select Clone.

    If a list of repositories doesn't appear, enter the location of your repo, and then select Clone.

    Screenshot of the Open from GitHub window where you can select a repo or add one.

  6. Next, Visual Studio presents a list of solution(s) in the repository. Choose the solution you would like to load or open the Folder View in Solution Explorer.

    Screenshot of the Folder View in Solution Explorer in Visual Studio 2022.

    Tip

    You can change the default Folder View to Solution View from the Git menu. Select Settings > Source Control > Git Global Settings > Automatically load the solution when opening a Git repository to do so.

Open an existing local repository

After you’ve cloned a repo or created one, Visual Studio detects the Git repository and adds it to your list of Local Repositories in the Git menu. From there, you can quickly access and switch between your Git repositories.

Browse to and then clone an Azure DevOps repo

  1. Open Visual Studio.

  2. From the Git menu, select Clone Repository.

    Screenshot of the full Clone Repository option from the Git menu in Visual Studio.

  3. In the Browse a repository section of the Clone a repository dialog box, select Azure DevOps.

    Screenshot of the 'Browse a repository' section of the 'Clone a repository' dialog box in Visual Studio, Azure DevOps highlighted.

  4. A Connect to a Project dialog box appears. Follow the prompts to sign in to your Azure account, and then browse to Azure DevOps Server that hosts the files you're looking for.

Next steps

To continue your journey, visit the Create a repo page.