Clone an existing Git repo
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019
Visual Studio 2019 | Visual Studio 2022
You can create a local copy of a remote Git repo by cloning it into a local folder on your computer. Cloning a remote repo downloads all commits on all branches of the repo, unless you use the --single-branch
clone option. Cloning links each branch in your new local repo with the corresponding branch in the remote repo. That way, when you push to share your local branch changes with your team, the corresponding remote branch is updated. Similarly, when you pull to update your local branch with changes made by your team, updates from the corresponding remote branch are retrieved. The remote repo can be an Azure Repos Git repo, a GitHub repo, or other hosted Git repo.
This article provides procedures for the following tasks:
- Get the clone URL for an Azure Repos Git repo
- Get the clone URL for a GitHub repo
- Clone an Azure Repos Git repo
- Clone a GitHub repo
- Clone any Git repo
- Open a Visual Studio solution from a cloned repo
For an overview of the Git workflow, see Azure Repos Git tutorial.
Prerequisites for access to Azure Repos
Repos must be enabled in your Azure DevOps project settings. If the Repos hub and associated pages don't display, see Turn an Azure DevOps service on or off to reenable Repos.
To view code in private projects, you must be a member of an Azure DevOps project with Basic access level or higher. For public projects, everyone can view the code.
If you don't have a project, create one or sign up for free.
If you aren't a project member, get added.
To clone or contribute to code for a private project, you must be a member of the Contributors security group or have the corresponding permissions set. For public projects, anyone can clone and contribute code. For more information, see What is a public project?
Note
For public projects, users granted Stakeholder access have full access to Azure Repos.
Repos must be enabled in your Azure DevOps project settings. If the Repos hub and associated pages don't display, see Turn an Azure DevOps service on or off to reenable Repos.
To view code, you must be a member of the Azure DevOps project with Basic access or higher. If you aren't a project member, get added.
To clone or contribute to code, you must be a member of the Contributors security group, or have the corresponding permissions, in the project you want to change.
Get the clone URL of an Azure Repos Git repo
Typically, you need to know the clone URL of the remote repo that you want to clone. The clone URL uniquely identifies the remote repo.
Note
When you're signed into an Azure DevOps project, Visual Studio supports searching for and cloning project repos without needing to know the clone URL.
From your web browser, open the team project for your Azure DevOps organization, and then choose Repos > Files to open the Files view.
In the Files view, choose Clone to launch the Clone Repository popup.
Copy the clone URL from the Clone Repository popup.
Note
With Azure DevOps Services, the format for the project URL is dev.azure.com/{your organization}/{your project}
. However, the previous format that references the visualstudio.com
format is still supported. For more information, see Introducing Azure DevOps, Switch existing organizations to use the new domain name URL.
Get the clone URL of a GitHub repo
Typically, you need to know the clone URL of the remote repo that you want to clone. The clone URL uniquely identifies the remote repo.
Note
When you're signed into GitHub, Visual Studio supports searching for and cloning GitHub repos without needing to know the clone URL.
Open a browser and navigate to your GitHub account, select the Repositories tab, and choose the repository to clone.
On the GitHub repository page, choose Code to launch the Clone popup. Copy the clone URL from the Clone popup.
Clone an Azure Repos Git repo
By signing in as a member of an Azure DevOps project, you can clone private repos that are accessible to you, and public repos. Visual Studio supports search, clone, and sync operations on repos that are accessible through authentication.
Note
You can clone a public Azure Repos Git repo without signing in as a member of its parent Azure DevOps project. To clone a public Git repo without signing in, see Clone any Git repo and then connect to a project in Azure DevOps.
- Visual Studio 2022
- Visual Studio 2019 - Git menu
- Visual Studio 2019 - Team Explorer
- Git Command Line
Visual Studio 2022 provides a Git version control experience by using the Git menu, Git Changes, and through context menus in Solution Explorer. Visual Studio 2019 version 16.8 also offers the Team Explorer Git user interface. For more information, see the Visual Studio 2019 - Team Explorer tab.
From the Git menu on the menu bar, choose Clone Repository to open the Clone a repository window.
In the Clone a repository window, select Azure DevOps under Browse a repository to open the Connect to a Project window.
In the Connect to a Project window, sign in to Azure DevOps and choose the remote repo you want to clone. You can use the search box to filter the list of remote repos. If you don't see the remote repo, select Add Azure DevOps Server to add the server that hosts the repo. Verify the local folder path where you want the local clone to be created, and then select Clone.
After you've cloned a remote Git repo, Visual Studio detects the local clone and adds it to the list of Local Repositories in the Git menu.
Clone a GitHub repo
By signing into GitHub or using SSH authentication, you can clone private repos that are accessible to you, and public repos. Visual Studio supports search, clone, and sync operations on repos that are accessible through authentication.
Note
You can clone a public GitHub repo without signing in to GitHub or otherwise authenticating. To clone a public Git repo without signing in, see Clone any Git repo.
- Visual Studio 2022
- Visual Studio 2019 - Git menu
- Visual Studio 2019 - Team Explorer
- Git Command Line
From the Git menu on the menu bar, choose Clone Repository to open the Clone a repository window.
In the Clone a repository window, select GitHub under Browse a repository to open the Open from GitHub window.
In the Open from GitHub window, sign in to GitHub and choose the remote repo you want to clone. You can use the search box to filter the list of remote repos. Verify the local folder path where you want the local clone to be created, and then choose Clone.
After you've cloned a remote Git repo, Visual Studio detects the local clone and adds it to the list of Local Repositories in the Git menu.
Clone any Git repo
You can clone any Git repo that's accessible to you by using the clone URL of the repo.
- Visual Studio 2022
- Visual Studio 2019 - Git menu
- Visual Studio 2019 - Team Explorer
- Git Command Line
From the Git menu on the menu bar, choose Clone Repository to open the Clone a repository window.
In the Clone a repository window, enter the clone URL of the remote Git repo that you want to clone, verify the local folder path where you want to create the local clone, and then choose Clone.
After you've cloned a remote Git repo, Visual Studio detects the local clone and adds it to the list of Local Repositories in the Git menu.
Open a Visual Studio solution from a cloned repo
- Visual Studio 2022
- Visual Studio 2019 - Git menu
- Visual Studio 2019 - Team Explorer
- Git Command Line