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.
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.
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.
You’ll also need a GitHub account. Go to github.com, and sign in to your 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:
- From the profile icon in the upper-right corner, select Your Repositories. It will show all the repositories in your GitHub account.
- Select the repository that you wish to clone to your computer. You’ll see your repository and the files within it.
- Click on code and copy the path. That’s the path to clone your repository directly to the VS Code.
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.
- Open VS Code
- Select the Source Control icon from the sidebar and then choose Clone Repository. It will open a command palette.
- In the command palette, paste the repository path you copied from GitHub. Then, press Enter on your keyboard.
- 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.
- A message will appear to open the cloned repository. Click on Open.
- 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.