Topic 3

Clone

Choose the clone workflow that matches where you are starting from. There are three ways to clone repositories in GitHub.

Outcome

The GitHub repository is cloned to a local project folder and opened in VS Code.

Before you start

  • Git and GitHub authentication are working.
  • The destination parent folder is known and writable.

Verification state

Status
Needs review
Environment
Windows is the detailed VS Code and GitHub Desktop path; command-line cloning also applies to macOS and Linux.
Workflow
VS Code, GitHub Desktop, and command-line clone entry points.
Last verified
Pending a current-product walkthrough.
Operating-system support
Windows detailed; macOS supported through equivalent apps; Linux supported through Git and VS Code commands.

First way

Open the Source Control view, choose Clone Repository, and select Clone from GitHub.

VS Code welcome screen for starting a clone workflow

Search for the repository you want to clone.

VS Code repository picker with GitHub repositories listed

If VS Code asks for a repository source, choose Clone from GitHub.

VS Code clone source picker with Clone from GitHub selected

Select the repository from the GitHub search results.

VS Code repository picker with a GitHub repository selected

Choose a destination folder for the clone before moving any project files.

Folder selection dialog for choosing a clone destination

After the clone finishes, open that cloned repository as the working folder before copying your project files into it.

VS Code after opening the cloned repository

Once the folder cloning is completed successfully, you will be able to see the following screen.

VS Code showing the cloned repository open in the Explorer

Second way

Copy the repository URL from GitHub.

GitHub repository page with the repository URL copy button highlighted

You can also paste the repository URL copied from GitHub directly into VS Code.

VS Code clone input for pasting a GitHub repository URL

Third way

Enter these commands in the terminal.

git clone <repository-url>
cd <repository-folder>

Fork

If you want to copy someone else’s public repository, use Fork.

GitHub repository page with the Fork button highlighted

If the cloned repository is open in VS Code and the project files are inside it, continue to the first commit and push workflow.

Common problems

  • Cloning into the wrong parent folder can create an unexpected nested project path.
  • A browser or VS Code authentication prompt must finish before a private repository can be cloned.

Completion check

git status runs inside the cloned folder and reports the expected branch without a repository error.