Clone and use a GitHub repository in Visual Studio Code

Learn the steps to clone a public repository from GitHub to your local computer using Visual Studio Code.

Clone repository

The act of cloning a GitHub repository means to bring the cloud-based source code into a local development environment.

This action isn't available from this feature. Select a different tab.

Visual Studio Code uses Git authentication provided by the operating system (such as macOS KeyChain or Windows Credential manager) with any git functionality. Output is visible in Command Palette > Git: Show Git Output.

Initialize new repository

If you don't have a GitHub repository yet, but would like to start your project locally, initialize your folder with git.

  1. Select source control from the activity bar, or use the key combination of Ctrl + Shift + G.

  2. Select Initialize repository.

    Screenshot of Visual Studio showing the Initialize repository button.

Create a branch for changes

Create a new branch to capture changes and isolate from the main or default branch.

  1. Select source control from the activity bar.
  2. Select ellipsis (...) next to Source Control.
  3. Select Branch -> Create Branch.

Commit changes locally

Once you have made changes on your branch, commit the changes.

  1. Select source control from the activity bar.

  2. Enter your commit message, then select Commit.

    Adding the yarn.lock file to Git

Push a local branch to GitHub

  1. Select the Source Control icon from the activity bar.
  2. Select Publish Branch. If the repository doesn't exist on GitHub, it creates the repository for you.

View Git output

You can view the Git commands run when you use the Source control extension. This helps debug when a command fails.

  1. Select the Source Control icon from the activity bar.

  2. Select the ellipsis (...) then select Show Git Output.

    Visual Studio Code source control, with the Show Git Output selection highlighted.

Visual Studio Code tools to work with Git and GitHub

Working in Visual Studio Code with a repository uses separate tools.

Icon Information Access from
Git commands in command palette F1
Source control extension Activity bar
Icon for GitHub PRs and Issues GitHub Pull Requests and Issues extension Activity bar
GitHub Repositories extension You can quickly and easily open a GitHub repository either by searching for GitHub Repositories: Open Repository... from the Command Palette, F1, or by choosing Open GitHub Repository... from the remote indicator (the green button in the lower left corner of the status bar).