Skip to main content

Using GitHub Codespaces for pull requests

You can use GitHub Codespaces in your web browser, or in Visual Studio Code to create pull requests, review pull requests, and address review comments.

Using a codespace to work on a pull request gives you all the benefits of GitHub Codespaces. For more information, see "GitHub Codespaces overview."

About pull requests in GitHub Codespaces

GitHub Codespaces provides you with many of the capabilities you might need to work with pull requests:

  • Create a pull request - Using either the Terminal and Git commands or the "Source Control" view, you can create pull requests just as you would on GitHub.com. If the repository uses a pull request template, you'll be able to use this within the "Source Control" view.
  • Open a pull request – You can open an existing pull request in a codespace, provided you have codespace access to the branch that is being merged in.
  • Review a pull request - Once you have opened a pull request in a codespace, you can use the "GitHub Pull Request" view to add review comments and approve pull requests. You can also use GitHub Codespaces to view review comments.

Opening a pull request in Codespaces

  1. Under your repository name, click Pull requests.

    Screenshot of the main page of a repository. In the horizontal navigation bar, a tab, labeled "Pull requests," is outlined in dark orange.

  2. In the list of pull requests, click the pull request you'd like to open in Codespaces.

  3. On the right-hand side of your screen, click Code.

  4. In the Codespaces tab, click .

    Screenshot of the "Code" dropdown with the "Codespaces" tab selected. The message "No codespaces" is displayed. The plus button is highlighted.

    A codespace is created for the pull request branch and is opened in your default editor for GitHub Codespaces.

Reviewing a pull request in Codespaces

  1. With your default editor set to either Visual Studio Code or Visual Studio Code for Web, open the pull request in a codespace, as described in "Opening a pull request in Codespaces" previously in this article.

  2. In the Activity Bar, click the Git pull request icon to display the "GitHub Pull Request" side bar. This icon is only displayed in the Activity Bar when you open a pull request in a codespace.

    Screenshot of the VS Code Activity Bar. The mouse pointer is hovering over an icon displaying the tooltip "GitHub Pull Request."

    If you opened a pull request in a codespace and the pull request icon is not displayed in the Activity Bar, make sure you are signed in to GitHub. Click the GitHub icon in the Activity Bar then click Sign in.

    Screenshot of the GitHub side bar showing the "Sign in" button. The GitHub icon in the Activity Bar is highlighted with an orange outline.

  3. To review the changes that have been made to a specific file, click the file's name in the "GitHub Pull Request" side bar.

    Screenshot of the "GitHub Pull Request" side bar. A file name is highlighted with a dark orange outline.

    This displays a diff view in the editor, with the version of the file from the base branch on the left, and the new version of the file, from the head branch of the pull request, on the right.

  4. To add a review comment, click the + sign next to the line number in the file displayed on the right side of the editor.

    Screenshot of the diff view. In the head version of the file, on the right side of the editor, the plus sign next to a line is highlighted.

  5. Type your review comment and then click Start Review.

    Screenshot of a comment being added, reading "Yes, I agree, this is clearer." The "Start Review" button is shown below the comment.

  6. Optionally, you can suggest a change that the author of the pull request can click to commit if they agree with your suggestion. To do this, click and hold the + sign next to the first line you want to suggest changing, then drag the + sign to the last line you want to suggest changing. Then click Make a Suggestion in the comment box that's displayed.

    The lines you selected are copied into the comment box, where you can edit them to suggest a change. You can add a comment above the line containing ```suggestion to explain your suggested change.

    Click Add Comment to add your suggestion to the pull request.

    Screenshot of a suggested change. The "Make a Suggestion" and "Add Comment" buttons are shown below the suggested change.

  7. When you are finished adding review comments, you can add a summary comment for your pull request review in the "GitHub Pull Request" side bar. You can then click Comment and Submit, or click the dropdown arrow and select Approve and Submit or Request Changes and Submit.

    Screenshot of the side bar showing the dropdown options "Comment and Submit," "Approve and Submit," and "Request Changes and Submit."

For more information on reviewing a pull request, see "Reviewing proposed changes in a pull request."

View comments from a review in Codespaces

Once you have received feedback on a pull request, you can open it in a codespace in your web browser, or in VS Code, to see the review comments. From there you can respond to comments, add reactions, or dismiss the review.