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
To get started, download the sample project, https://github.com/Azure-Samples/js-e2e-express-server
, using the following steps:
Open the command palette with the key combination of Ctrl + Shift + P.
At the command palette prompt, enter
gitcl
, select the Git: Clone command, then select Clone from GitHub and press Enter.When prompted for the Repository URL, select clone from GitHub, then press Enter.
If you are asked to sign into GitHub, complete the sign-in process.
Enter azure-samples/js-e2e-express-server in the Repository URL field.
Select (or create) the local directory into which you want to clone the project.
When you receive the notification asking if you want to open the cloned repository, select Open.
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.
Select source control from the activity bar, or use the key combination of Ctrl + Shift + G.
Select Initialize repository.
Create a branch for changes
Open the command palette with the key combination of Ctrl + Shift + P.
Search for
git branch
and selectGit: Create Branch
.Enter a new branch name, such as
test
.The branch name is visible in the status bar.
Commit changes locally
Once you have made changes on your branch, commit the changes.
Open the command palette with the key combination of Ctrl + Shift + P.
In the command palette, filter with
Git
then selectCommit
.Enter your commit message, then press Enter.
Push a local branch to GitHub
- Open the command palette with the key combination of Ctrl + Shift + P.
- In the command palette, filter with
Git
then selectPush
. - If you have multiple upstream remotes, select the remote then press Enter.
View Git output
You can view the Git commands run when you use the Source control extension. This helps debug when a command fails.
Select the Source Control icon from the activity bar.
Select the ellipsis (...) then select Show Git Output.
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 |
![]() |
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). |
Next steps
Feedback
Submit and view feedback for