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.

Tools Required

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.

How To 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 To View 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
    From Code, Copy The URL or Path.

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 On 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
This is Proof Of Your Successful Cloning.

Was this article helpful?

Leave a Comment