Work with GitHub in VS Code
AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. Join VS Code at Microsoft Ignite or catch the sessions online. A year of VS Code, wrapped. Explore the highlights. Work with GitHub in VS Code View as Markdown Ask in VS Code Ask in VS Code Insiders Visual Studio Code provides several ways to work with repositories, pull requests, and issues on GitHub .
Basic GitHub authentication and Git operations are built into VS Code. Extensions add pull request, issue, and virtual repository workflows. Choose an integration below, or go directly to creating a pull request , reviewing a pull request , or working on an issue . Tip New to Git in the editor? Complete the source control quickstart before starting a collaboration workflow. Choose a GitHub workflow Choose an integration based on what you want to do: Goal Capability Requirement Clone, fetch, pull, and push Built-in Git support Install Git and sign in when prompted.
Create and review pull requests or manage issues GitHub Pull Requests and Issues extension Install the extension and sign in. Browse and edit without cloning GitHub Repositories extension Install the extension and sign in. Terminal, build, and debugging workflows require a different environment. The GitHub Pull Requests and Issues and GitHub Repositories extensions are separate. Install only the extension that supports your workflow.
Prerequisites For a local checkout, install Git and configure your commit identity . To publish changes, create pull requests, or manage issues, you also need a hosting account . Signing in does not grant write permission to every repository. If you can't push to the project, create a fork , work in your fork, and open a pull request to the original project. Sign in to GitHub for Git operations You don't need an extension to authenticate Git operations with GitHub.
When you clone a private repository or push to a GitHub repository, VS Code prompts you to sign in. Follow the browser prompts, then return to VS Code. Personal access token authentication is supported for GitHub Enterprise Server. To use a personal access token, cancel the browser sign-in prompts until VS Code asks for a token. For other authentication options, see GitHub authentication methods . Get started with GitHub Pull Requests and Issues After you install the GitHub Pull Requests and Issues extension, sign in to use pull request and issue features.
Select the GitHub icon in the Activity Bar. Select Sign In and follow the browser prompts. Return to VS Code when authentication is complete. If you are not redirected to VS Code, you can add your authorization token manually: In the browser window, copy your authorization token. In VS Code, select Signing in to github.com... in the Status Bar. 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. Learn more about cloning repositories and working with remotes . 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 . Pull requests Use the GitHub Pull Requests and Issues extension's Pull Requests view to create or review a proposed change.
Creating pull requests Open your local repository, create a branch , and commit your changes . Run GitHub Pull Requests: Create Pull Request from the Command Palette ( ⇧⌘P (Windows, Linux Ctrl+Shift+P ) ), or select Create Pull Request in the Pull Requests view. In the Create view, select the base repository and branch that should receive your changes. Enter a title and description. If the repository has a pull request template, the extension fills in that template.
Select Create . If your branch isn't published, choose a remote you can push to, such as your fork, when prompted. The extension opens the pull request in Review Mode . Verify the destination branch and changed files before requesting review. Use the action bar to add Assignees , Reviewers , Labels , or a Milestone . For unfinished work, use Create Draft from the Create button menu. Other options, such as Auto-Merge , depend on repository support and your permissions.
Reviewing Select a pull request in the Pull Requests view to open its Description . To inspect and test the code locally, first commit or stash your current changes , then select Checkout . The extension checks out the pull request branch and enters Review Mode . The Changes in Pull Request view lists the changed files and commits. Select a file to inspect its diff and add comments. Use Open File to open the working file.
Local navigation, IntelliSense, and editing are available in this checked-out workflow. Submit your comments or review from the pull request Description . Approval and merge actions depend on your permissions and the repository's rules. When finished, select Exit Review Mode to return to your previous branch. Preserve any local edits before switching. Customize the pull request list Configure githubPullRequests.queries Open in VS Code Open in VS Code Insiders to choose which pull requests the view shows.
Queries use the GitHub search syntax . For example, add this setting to your settings JSON file : { "githubPullRequests.queries" : [ { "label" : "Assigned To Me" , "query" : "is:open assignee:${user}" } ] } Use AI assistance for pull requests AI assistance is optional. To generate a pull request title and description, select the sparkle icon next to the title field, then review the generated text. This action uses the utility model configured by chat.utilitySmallModel Open in VS Code Open in VS Code Insiders , not the model selected for a chat or agent session.
See utility model setup and requirements . You can also review proposed changes with AI before creating the pull request. Review the feature requirements in that guide and select Code Review in the GitHub Pull Request view. Issues Creating issues Issues can be created from the + button in the Issues view and by using the GitHub Issues: Create Issue from Selection and GitHub Issues: Create Issue from Clipboard commands.
They can also be created using a Code Action for "TODO" comments. When creating issues, you can take the default description or select the Edit Description pencil icon in the upper right to bring up an editor for the issue body. You can configure the trigger for the Code Action using the GitHub Issues: Create Issue Triggers ( githubIssues.createIssueTriggers Open in VS Code Open in VS Code Insiders ) setting. The default issue triggers are: "githubIssues.createIssueTriggers" : [ "TODO" , "todo" , "BUG" , "FIXME" , "ISSUE" , "HACK" ] Working on issues From the Issues view, you can see your issues and work on them.
By default, when you start working on an issue ( Start Working on Issue context menu item), a branch will be created for you, as shown in the Status Bar in the image below. The Status Bar also shows the active issue and if you select that item, a list of issue actions are available such as opening the issue on the GitHub website or creating a pull request. You can configure the name of the branch using the GitHub Issues: Issue Branch Title ( githubIssues.issueBranchTitle Open in VS Code Open in VS Code Insiders ) setting.
If your workflow doesn't involve creating a branch, or if you want to be prompted to enter a branch name every time, you can skip that step by turning off the GitHub Issues: Use Branch For Issues ( githubIssues.useBranchForIssu
The rest of this page is on the live site.