Skip to content

Latest commit

 

History

History
136 lines (83 loc) · 5.94 KB

clone.md

File metadata and controls

136 lines (83 loc) · 5.94 KB
title titleSuffix description ms.assetid ms.technology ms.topic ms.date monikerRange
Clone an existing Git repo
Azure Repos
Create a local clone of an existing repo using Visual Studio or command prompt
b6240e2f-2d3d-4874-9953-7e554d5e3b97
devops-code-git
tutorial
11/13/2020
<= azure-devops

Clone an existing Git repo

Azure Repos | Azure DevOps Server 2020 | Azure DevOps Server 2019 | TFS 2018 | TFS 2017 | TFS 2015 | VS 2017 | VS 2015

Create a complete local copy of an existing Git repository by cloning it. Cloning a repo downloads all commits and branches in the repo. Cloning sets up a named relationship with the existing repo you cloned. Use this relationship to interact with the existing repo, pushing and pulling changes to share code with your team.

Note

By default, Git assigns the origin to the remote repo you clone from. Most users don't need more than one remote, so the tutorial uses origin in its steps. Learn more about setting up remotes to your Git repo.

In this tutorial you learn how to:

[!div class="checklist"]

  • Get the clone URL to your repo
  • Clone a repo

Video tutorial

<iframe src="https://channel9.msdn.com/series/Team-Services-Git-Tutorial/Git-Tutorial-Create-a-Git-repo-in-Visual-Studio-2015/player" width="560" height="315" allowFullScreen frameBorder="0"></iframe>

Tip

Working from the command line? You can view our video tutorial using command line steps on Channel9.

Get the clone URL to your repo

Before you can clone an existing repo, you'll need a URL that points to the existing repo. This URL represents the source of the repo you're going to copy.

If you're using Azure Repos, Azure DevOps Server 2019, or Team Foundation Server, you can find this clone URL in the web portal.

  1. From your web browser, open the team project for your Azure DevOps organization and choose Repos, then Files.

    Repos files

  2. Select Clone in the upper right.

    Get a clone a URL from Azure Repos

If you need to clone a GitHub repo, you'll need to get the clone URL. Use the Clone or download button while viewing the repo on the web in GitHub.

Other Git providers have similar buttons in their user interface to get the clone URL.

Copy this URL into the clipboard or store it in a place where you can find it easily. You can't clone a repo without a clone URL.

Clone a repo

[!INCLUDE temp]

Clone from Azure Repos / Azure DevOps Server

  1. In Team Explorer, open the Connect page by selecting the Connect button. Choose Manage Connections then Connect to Project.

    Cloning Azure Repos Git repositories in Visual Studio

  2. In Connect to a Project, select the repo you want to clone from the list and select Clone.

    Cloning a Git Repository from a connected Azure DevOps organization

    If you don't see your repo listed, filter the list to find it. You may need to add an Azure DevOps Server where the repo is hosted. Select the Add Azure DevOps Server link.

    [!INCLUDE project-urls]

  3. Verify the location of the cloned repo on your PC and select Clone.

Clone from another Git provider

If you aren't using Azure Repos, you can still clone your repo in Team Explorer and work with your code in Visual Studio.

  1. In Team Explorer, open the Connect view, as explained above.

  2. Select Clone under Local Git Repositories and enter the URL for your Git repo. Your team or Git hosting provider gives you this URL.

  3. Select a folder where you want your cloned repo.

  4. Select Clone to clone the repo.

    Clone your repo from other providers using Visual Studio

Open a solution in Visual Studio from a cloned repo

  1. Right-click on a repository in the Team Explorer Connect view and select Open.

    Open a solution from a cloned repo in Team Explorer

In the Home view in Team Explorer, double-click your project solution file in the Solutions area. The solution opens in Solution Explorer.

Double-click your project solution file in the Solutions area to open it in Team Explorer.

Prerequisites

You'll need a clone URL to tell Git what repository you want to clone to your computer. Use the URL you copied earlier during the previous step in this article.

Use this clone URL with git clone to make a local copy of the repo:

git clone https://dev.azure.com/fabrikam/DefaultCollection/_git/Fabrikam

git clone clones the repository from the URL in a folder under the current one. You can specify a folder name after the URL to create the repo in a specific location, for example:

git clone https://dev.azure.com/fabrikam/DefaultCollection/_git/Fabrikam C:\Repos\FabrikamFiber

Next steps

[!div class="nextstepaction"] Save work with commits