Explore Agentic Development -

Working with GitHub in VS Code

GitHub is a cloud-based service for storing and sharing source code. Using GitHub with Visual Studio Code lets you share your source code and collaborate with others right within your editor. There are many ways to interact with GitHub, for example, via their website at https://github.com or the Git command-line interface (CLI), but in VS Code, the rich GitHub integration is provided by the GitHub Pull Requests and Issues extension.

In this topic, we'll demonstrate how you can use some of your favorite parts of GitHub without leaving VS Code.

Tip

If you're new to source control or want to learn more about VS Code's basic Git support, you can start with the Source Control topic.

Prerequisites

To get started with GitHub in VS Code, you need:

Getting started with GitHub Pull Requests and Issues

Once you've installed the GitHub Pull Requests and Issues extension, you'll need to sign in.

  1. Select the GitHub icon in the Activity Bar

  2. Select Sign In and follow the prompts to authenticate with GitHub in the browser

    Screenshot of the GitHub view, showing the sign in button.

  3. You should be redirected back to VS Code

If you are not redirected to VS Code, you can add your authorization token manually:

  1. In the browser window, copy your authorization token
  2. In VS Code, select Signing in to github.com... in the Status Bar
  3. Paste the token and press Enter to complete the sign-in process

Setting up a repository

Cloning a repository

You can search for and clone a repository from GitHub using the Git: Clone command in the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) or by using the Clone Repository button in the Source Control view (available when you have no folder open).

From the GitHub repository dropdown you can filter and pick the repository you want to clone locally.

Screenshot showing the GitHub repository Quick Pick filtered on microsoft/vscode.

Learn more about cloning repositories and working with remotes.

Authenticating with an existing repository

Enabling authentication through GitHub happens when you run any Git action in VS Code that requires GitHub authentication, such as pushing to a repository that you're a member of or cloning a private repository. You don't need to have any special extensions installed for authentication; it is built into VS Code so that you can efficiently manage your repository.

When you perform an action that requires GitHub authentication, VS Code prompts you to sign in. Follow the steps to sign into GitHub and return to VS Code.

Screenshot showing the GitHub authentication dialog.

Signing in with a personal access token (PAT) is only supported with GitHub Enterprise Server. If you're using GitHub Enterprise Server and want to use a PAT, you can select Cancel on the sign in prompts until you are prompted for a PAT.

Note that there are several ways to authenticate to GitHub, including using your username and password with two-factor authentication (2FA), a personal access token, or an SSH key. See About authentication to GitHub for more information and details about each option.

Note

If you'd like to work on a repository without cloning the contents to your local machine, you can install the GitHub Repositories extension to browse and edit directly on GitHub. Learn more about the GitHub Repositories extension.

Editor integration

Hovers

When you have a repository open and a user is @-mentioned (for example, in a code comment), you can hover over that username and see a GitHub-style hover with the user's details.

Screenshot showing a user hover for a @-mentioned user in a code comment.

There is a similar hover for #-mentioned issue numbers, full GitHub issue URLs, and repository specified issues.

Screenshot showing a hover for a #-mentioned issue number in a code comment.

Suggestions

User suggestions are triggered by typing the "@" character and issue suggestions are triggered by typing the "#" character. Suggestions are available in the editor and in the Source Control commit message input box.

GIF showing User and Issue suggestions in the editor.

The issues that appear in the suggestion can be configured with the GitHub Issues: Queries ( githubIssues.queries