Cloning Git Repositories in Visual Studio Team Explorer

There are endless code repositories out there, and you can access them with a simple URL. For example, a repo hosted on Github might look like:

https://github.com/PowerShell/PowerShell.git

Note the .git extension at the end. That URL is the location of a repository i.e. a bunch of code and history of commits/developers that have worked on the repository. On the command line, we would use the git clone command to copy that repository down to our developer machine, but this article is about using Visual Studio and/or Team Explorer within Visual Studio to do so.

Cloning after opening Visual Studio

When you open Visual Studio 2019, the very first button on the right is Clone or checkout code. As all things Microsoft can be, this is a wizard-y experience.

Clicking that button launches the short wizard below. Simply paste the URL of your choice of git repo into the Repository location input and choose a location to store it on your machine (Local path.)

When you click Clone, Visual Studio will either begin copying the repository to your machine or it might prompt you for credentials if you’re working in a private repository and it doesn’t have an identity with which to authenticate you.

If you happen to have your Output pane open, you might see something like the below log. Don’t worry if you don’t, it’s still cloning the repository!

Visual Studio may open the solution for you, or you may need to find Team Explorer (further down in this article) and open the solution manually. Either way, you’ve cloned a code repository!

Cloning in Team Explorer

Alternatively, if you started Visual Studio, whether working in a solution or project or not, you can view Team Explorer by finding the tab (possibly somewhere near Solution Explorer) or you can force it open by clicking View => Team Explorer in Visual Studio’s menu.

Once you’ve opened Team Explorer, a set of inputs is available similar to the wizard experience above. Copy your repo URL, choose a location on disk, and click Clone.

You might see something like the screenshot below, but ultimately Visual Studio should have cloned your repository.

You should see an indication that your repository has been cloned–something like this:

If you double-click that item in your list of repositories, you should land on the Team Explorer home page and see a list of solutions (Visual Studio can identify .sln files) near the bottom of the pane.

Double-clicking the .sln item in that list should ultimately open Solution Explorer, and you can begin hacking away!

Summary

We learned how to clone a repository using vanilla Visual Studio and also how to clone repositories via Team Explorer. Browse around Github and see if there are any repositories that interest you!

Leave a Reply