How to Clone A GitHub Repository in Visual Studio Code

GitHub is a fantastic tool that powers millions of developers every day to get their work done, share code, and collaborate on projects. In addition, it provides hosting services for Git repositories. In this article, you’ll learn to clone a GitHub repository to your local machine and connect it to Visual Studio Code.

Step 1: Install required tools

Before we start exploring the steps to clone repositories to VS Code, let’s make sure your computer has everything installed to clone repositories.

Git

You’ll need to have Git installed on your computer. You can visit git-scm.com/downloads, and there you will find the download for your operating system. Install it with default settings.

Download Git
Download and install Git.

Visual Studio Code

Next, you’ll need Visual Studio Code. Head over to code.visualstudio.com and download the version for your operating system, whether Mac, Windows, or Linux. After downloading, install it with default settings.

VS Code
Download and install VS Code.

GitHub

You’ll also need a GitHub account. Go to github.com, and sign in to your account.

Github Website
Log in to your GitHub account.

Now that you have downloaded and installed the required tools, you’ll need to create a folder on your local computer at your preferred directory. This folder will contain all of your repository files. In my case, I have created a folder named VS Code on the desktop.

Step 2: Get the repository Path/URL?

To clone a repository, you’ll need the repository path. Follow these steps to get it:

  1. From the profile icon in the upper-right corner, select Your Repositories. It will show all the repositories in your GitHub account.

    Your Repositories
    Click on Your Repositories.

  2. Select the repository that you wish to clone to your computer. You’ll see your repository and the files within it.

    Select the repository
    Select the repository you want to clone to your computer.

  3. Click on code and copy the path. That’s the path to clone your repository directly to the VS Code.

    Repository Path
    Under Code, click the the copy URL icon.

Step 3: Clone a GitHub repository in the VS Code interface

Now that you have the repository path, you’re ready to clone the GitHub repository to your local computer using VS Code.

  1. Open VS Code
  2. Select the Source Control icon from the sidebar and then choose Clone Repository. It will open a command palette.

    Clone A GitHub Repository
    Click Clone Repository from the Source Control Icon on the sidebar.

  3. In the command palette, paste the repository path you copied from GitHub. Then, press Enter on your keyboard.

    Paste Repository Path
    In the command palette, paste the repository path.

  4. Now, select the directory where you want to place the clone. For example, I have created a folder named VS Code on my desktop. This will be my directory – you can create your own folder and name it what you like.

    Choose Directory
    Choose your preferred directory to save the clone file.

  5. A message will appear to open the cloned repository. Click on Open.

    Open the Cloned Repository
    From the message prompt, click Open.

  6. When done, Visual Studio Code will switch views, and in the top-left corner, you can see the repository folder and the files inside it. Voilà! You have successfully cloned the GitHub repository in your local computer through Visual Studio Code.

    Cloned File
    Proof of successful cloning.

Leave a Comment