Clone a Git repository in a public project

Azure DevOps Services

You can create a complete local copy of a Git repository from a public project by cloning it. Cloning a repo downloads all commits and branches in the repo and sets up a named relationship with the existing repo you cloned. If you are signed in as a member of the project, you can use this relationship to interact with the existing repo, pushing and pulling changes to share code with the public project team.

Note

By default you have read-only access to the code in the repository. To perform operations such as forking, creating branches, and making pull requests, you must be invited to contribute. If you just want a copy of the code to review, instead of cloning you can download the code.

Get the clone URL of the Git repo

Before you can clone the repo from a public project, you'll need the clone URL.

  1. To open a repository, choose Repos>Files.

    Open Repos>Files, anonymous user

  2. Choose the repository you want to clone from the repository selector.

    Select repository

  3. Choose Clone. In the Clone repository dialog, choose the Clone URL copy-clone icon to have the URL copied to your clipboard. Store it in a place where you can find it easily.

    Clone URL, new navigation

Clone the repo to your local computer

Note

The steps in this section show how to clone a public project Git repo in Visual Studio when you are not a member of the project. For instructions for cloning a public project Git repository when you are signed in to Visual Studio as a member of the public project, see Clone a Git repo.

Clone using Visual Studio and Team Explorer

Note

Visual Studio 2019 version 16.8 and later versions provide a new Git menu for managing the Git workflow with less context switching than Team Explorer. Procedures provided in this article under the Visual Studio 2019 tab provide information for using the Git experience as well as Team Explorer. To learn more, see Side-by-side comparison of Git and Team Explorer.

  1. In Team Explorer, (1) open up the Connect page by selecting the Connect icon. (2) Choose Clone under Local Git Repositories, (3) enter the clone URL, verify your local folder in which to clone, and (4) select the Clone button.

    Connecting to Azure DevOps

  2. After cloning, you have a local Git repository containing the code of the repository you cloned. You can view and make local changes, but in order to push changes and make pull requests to the remote repository, you must be invited to contribute.

Clone using the command line

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.

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

git clone https://dev.azure.com/public1/MyFirstProject/_git/MyGreatLibrary

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

git clone https://dev.azure.com/public1/MyFirstProject/_git/MyGreatLibrary C:\Repos\MyGreatLibrary