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.
Search for the repository you want to clone.
If VS Code asks for a repository source, choose Clone from GitHub.
Select the repository from the GitHub search results.
Choose a destination folder for the clone before moving any project files.
After the clone finishes, open that cloned repository as the working folder before copying your project files into it.
Once the folder cloning is completed successfully, you will be able to see the following screen.
Second way
Copy the repository URL from GitHub.
You can also paste the repository URL copied from GitHub directly into VS Code.
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.
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.