How to Clone Git repository from GitHub in Visual Studio Code?

Start cloning your GitHub git repository directly in your Visual Studio Code on Windows 11 or 10 operating system for creating and managing remote projects…

GitHub is a popular platform that uses Git a distributed version control system. It allows hosting and collaborating on software projects. Microsoft’s Visual Studio Code (VS Code) is a developing platform published under an open-source license. Combining the power of GitHub with the convenience of VS Code allows developers to work on their projects and collaborate with others efficiently. Let’s learn the process of cloning a Git repository from GitHub into Visual Studio Code. 

Steps to Clone a Git Repository in Visual Studio Code

Prerequisites

To start with the tutorial you must have Visual Studio Code on your Windows system along with GitHub Account and an active internet connection.

Step 1: Install Git on Windows 10 or 11

If you already have git installed on your Windows system then skip this step and move to the next one. However, those who don’t have Git can open their PowerShell or Terminal as Admin by clicking on the Windows Start button and can install it using the given command. Alternatively, one can download it from the official website of Git.

winget install --id Git.Git

Step 2: Open Visual Studio Code

Launch Visual Studio Code on your computer by searching for it in the Windows Start menu. If you haven’t already installed it, you can download it from the official website or by running a command in Terminal or PowerShell i.e. –  winget install Microsoft.VisualStudioCode

Step 3: Access Git: Clone command

Once you have opened the VSCode, press Ctlr+Shift+P to open the command palette. There type gitcl, you will see Git: Clone in the search results, select it.

Git Clone in the command platte Vscode

After that, you will be asked to provide the repository URL, as we want to clone the repo from GitHub instead of providing the URL, just click on the “Clone from GitHub” option.

Clone from GitHub

You will be prompted to sign in to your GitHub Account. Just click on the Allow button and a browser will be opened.

Sign in with your GitHub account- username and password.

Sign into GitHub

Step 4: Authorize GitHub for VS Code

As you log in, VS code will ask your permission to access data and the repository available on your GitHub account. Click on the Authorize Visual-Studio-Code button.

Authorize GitHub for VS Code

Step 5: Clone the GitHub Git Repository

Now, paste the Git repository that you want to clone in the Repository URL field of Visual Studio Code and hit the Enter key.

As you do this, VSCode will open the file manager on your system to select the folder where you want to save the project or repository that it going to clone using the given URL.

So, select any existing folder or create a new one as your Git Repository Destination folder.

Select Repository destination folder

Now, you will be asked what you would like to do with the Cloned Git Repository. Whether you want to open it to add it to your current workspace, the choice is yours.

Here we are selecting the Open option.

Open the Cloned Git repository in VSCode

The Cloned repository files will be listed on your Visual Studio Code Interface.

Clone Git GitHub repository Vscode Windows 10 or 11

How to Create a Branch

We know now the process of cloning a Git repo in VScode, after that, if you want to create a New Branch or want to perform other Git Tasks then the options for them are available in the Command palette.

For example, if you want to create a new branch then go to Source Control and select the repository.

Press Ctrl+Shift+P and then type – Git branch, select the Git Create Branch, and give some name to your Branch.

Similarly, you can Commit the changes and push the local branch to Github as well.

Git Create branch

Other Articles: