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:
- View code in private projects: At least Basic access. - Clone or contribute to code in private projects: Member of the Contributors security group or corresponding permissions in the project. - Set branch or repository permissions: Manage permissions permissions for the branch or repository. - Change default branch: Edit policies permissions for the repository. - Import a repository: Member of the Project Administrators security group or Git project-level Create repository permission set to Allow. For more information, see Set Git repository permissions.
- View code: At least Basic access. - Clone or contribute to code: Member of the Contributors security group or corresponding permissions in the project.
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.
Piezīme
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.
Svarīgi
The "Generate Git Credentials" button will be removed in January 2025, to reduce creation of unnecessary and underutilized personal access tokens. Review the Git Authentication docs for all authentication methods available to you for git clone operations.
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.
Piezīme
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 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.
Visual Studio 2019 provides a Git version control experience by using the Git menu, Git Changes, and through context menus in Solution Explorer.
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.
Visual Studio 2019 version 16.8 and later versions provides a Git version control experience while maintaining the Team Explorer Git user interface. To use Team Explorer, uncheck Tools > Options > Preview Features > New Git user experience from the menu bar. You can use Git features from either interface interchangeably.
In Team Explorer, select Connect to open the Connect page, and then choose Manage Connections > Connect to Project.
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.
To clone an Azure Repos Git repo from the command line, see Clone any Git repo.
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.
Piezīme
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.
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.
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.
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.
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.
In Team Explorer, select Connect to open the Connect page, and then choose Clone under Local Git Repositories.
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. To clone the remote Git repo and any Git repos that are nested within it, leave Recursively Clone Submodules checked.
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.
At the command prompt, run the Git clone command with the clone URL of the remote repo. This command will create a local clone repo under the current folder.
Console
git clone <clone URL>
The Git clone command also let's you specify a folder path after the clone URL to create the repo in a specific location. For example:
When you clone a remote repository, Git assigns the alias origin as shorthand for the URL of the remote repo you cloned. Git commands often use that alias.
Pievienojieties meetup sērijai, lai kopā ar citiem izstrādātājiem un ekspertiem izveidotu mērogojamus AI risinājumus, kuru pamatā ir reālas lietošanas gadījumi.
Hands-on module focused on getting the learner comfortable with basic source control commands through an integrated development environment or web portal.