Cloning a repository to your local machine

Kevin Wu
4 min readAug 29, 2019

This is a part of a series of simple step by step guide on simplifying and automating software development using Azure DevOps.

This article is a continuation of a previous article on creating a personal access token, if you haven’t already, follow the steps in this article ‘Creating a Personal Access Token’ first.

Before we can proceed further, there are some pre-requisites that we need to take care of first. We need to make sure that these applications are installed on the local machine.

  1. Git https://git-scm.com/downloads
  2. .Net Core SDK https://dotnet.microsoft.com/download
  3. Visual Studio Code https://code.visualstudio.com/

Once you have all the applications setup and installed. To start cloning the files from our repository to our local machine. Click on the ‘Clone’ button at the top right corner of our file repository. Copy the clone URL, make sure you are copying the HTTPS url. (Image 1)

Copy Clone URL
Image 1

Once you have copied the URL, we need to add the Personal Access Token that we’ve created previously to the URL. We will use this Url for accessing the remote repository later on.

The original git url format is usually

https://{user}@dev.azure.com/{repository url}

Add the personal access token in between the {user} and ‘@’ symbol like this

https://{user}:{personal access token}@dev.azure.com/{repository url}

For example:

https://paranoidy:4mxdhgdjoa32h4mvz5zerfsde234@dev.azure.com/paranoidy/AspNetCore-Realworld-CICD-Example/_git/aspnetcore-realworld-example-app

Copy this Git Url with the Personal access token added. We will use this to clone the repository into our local machine.

Start the Command Shell in your local machine, go to the folder you wish to store your project source code.

Image 2

At the command prompt type in the command:

> git clone {your git url with personal access token}

The files from your Azure repository will be cloned into your local machine. (Image 3)

Image 3

Once the process completes, go to the local project folder and type the command:

> code .

Don’t forget the ‘ . ’ (Image 4)

Image 4

This will start Visual Studio Code (VS Code) with the project loaded. When you load VS Code for the first time, click ‘Yes’ to the C# extension and ‘Restore’ for the request to restore dependencies. (Image 5)

Image 5

To run the application, open the VS Code powershell. To do that, from VS Code at the top menu, click ‘View’ and click ‘Terminal’. Or you can use the short cut Ctrl + `

From the Powershell terminal, go to the folder src\Conduit

> cd src\Conduit

Run the .Net Core application

> dotnet run

Image 6

This will start the application on your machine. You should see this from your Powershell terminal. (Image 7)

Image 7

To make sure it’s working, open up your browser and type the Url

http://localhost:5000/swagger

If all goes well, you should see the swagger UI for our project. (Image 8)

Image 8

Hurray! Now that we’ve settled the basic stuff, it’s time to get serious.
Next we will be talking about GitFlow to handle our branching and merging needs.

--

--