Skip to main content

Reviewing proposed changes in a pull request

In a pull request, you can review and discuss commits, changed files, and the differences (or "diff") between the files in the base and compare branches.

About reviewing pull requests

You can review changes in a pull request one file at a time. While reviewing the files in a pull request, you can leave individual comments on specific changes. After you finish reviewing each file, you can mark the file as viewed. This collapses the file, helping you identify the files you still need to review. A progress bar in the pull request header shows the number of files you've viewed. After reviewing as many files as you want, you can approve the pull request or request additional changes by submitting your review with a summary comment.

提示:可使用搜索限定符 review-requested:[USERNAME]team-review-requested:[TEAMNAME] 查找请求你或你所属团队审查的拉取请求。 有关详细信息,请参阅“搜索问题和拉取请求”。

Starting a review

  1. 在存储库名称下,单击 “拉取请求”。 问题和拉取请求选项卡选择

  2. 在拉取请求列表中,单击要审查的拉取请求。

  3. On the pull request, click Files changed. Pull Request Files changed tab

    You can change the format of the diff view in this tab by clicking and choosing the unified or split view. The choice you make will apply when you view the diff for other pull requests.

    Diff view settings

    You can also choose to hide whitespace differences. The choice you make only applies to this pull request and will be remembered the next time you visit this page.

  4. Optionally, filter the files to show only the files you want to review or use the file tree to navigate to a specific file. For more information, see "Filtering files in a pull request."

  5. 将鼠标悬停在要添加评论的代码行上方,然后单击蓝色的评论图标。 若要在多行上添加评论,请单击并拖动以选择行范围,然后单击蓝色的评论图标。 蓝色评论图标

  6. 在评论字段中输入您的评论。 注释字段

  7. Optionally, to suggest a specific change to the line or lines, click , then edit the text within the suggestion block. Suggestion block

  8. When you're done, click Start a review. If you have already started a review, you can click Add review comment.

    Start a review button

Before you submit your review, your line comments are pending and only visible to you. You can edit pending comments anytime before you submit your review. To cancel a pending review, including all of its pending comments, scroll down to the end of the timeline on the Conversation tab, then click Cancel review.

Cancel review button

You can use GitHub Codespaces to test, run, and review pull requests.

  1. Open the pull request in a codespace, as described in "Opening a pull request."

  2. In the Activity Bar, click the GitHub Pull Request view. This view only appears when you open a pull request in a codespace.

    Option to open PR in a codespace

  3. To review a specific file, click the Open File icon in the Side Bar.

    Option to open PR in a codespace

  4. To add review comments, click the + icon next to the line number. Type your review comment and then click Start Review.

    Option to open PR in a codespace

  5. When you are finished adding review comments, from the Side Bar you can choose to either submit the comments, approve the changes, or request changes.

    Option to open PR in a codespace

For more information on reviewing pull requests in GitHub Codespaces, see "Using GitHub Codespaces for pull requests."

Reviewing dependency changes

If the pull request contains changes to dependencies you can use the dependency review for a manifest or lock file to see what has changed and check whether the changes introduce security vulnerabilities. For more information, see "Reviewing dependency changes in a pull request."

  1. On the pull request, click Files changed. Pull Request Files changed tab

  2. On the right of the header for a manifest or lock file, display the dependency review by clicking the rich diff button.

    The rich diff button

  3. 您可能还想查看源差异,因为清单或锁定文件可能会发生变化,但不会更改依赖项,也可能存在 GitHub 无法解析的依赖项,因此,这些依赖项不会显示在依赖项审核中。

    要返回到源差异视图,请单击 按钮。


Marking a file as viewed

After you finish reviewing a file, you can mark the file as viewed, and the file will collapse. If the file changes after you view the file, it will be unmarked as viewed.

  1. On the pull request, click Files changed. Pull Request Files changed tab

  2. On the right of the header of the file you've finished reviewing, select Viewed.

    Viewed checkbox

Submitting your review

After you've finished reviewing all the files you want in the pull request, submit your review.

  1. On the pull request, click Files changed. Pull Request Files changed tab

  2. 在更改的代码上方,单击“审阅更改”。 “审阅更改”按钮

  3. 输入评论,概述您对拟议更改的反馈。 审查摘要评论窗口

  4. Select the type of review you'd like to leave:

    Radio buttons with review options

    • Select Comment to leave general feedback without explicitly approving the changes or requesting additional changes.
    • Select Approve to submit your feedback and approve merging the changes proposed in the pull request.
    • Select Request changes to submit feedback that must be addressed before the pull request can be merged.
  5. 单击“提交审查”。


  • 如果启用了必需的审查,并且对存储库具有写入、管理员或所有者访问权限的协作者提交请求更改的审查,则在同一协作者提交另一次要求批准拉取请求中更改的审查之前,拉取请求不能合并 。
  • 即使没有获得批准审查,或者请求更改的审查者离开了组织或者联系不上,仓库所有者和管理员也可合并拉取请求。
  • 如果同时启用了必需审查和过期审查,并且代码修改提交已推送到批准的拉取请求分支,则批准将予驳回。 拉取请求必须经过再次审查和批准才可合并。
  • 当多个打开的拉取请求时分别有指向同一提交的头部分支时,如果一个或两者有待定或被拒绝的审查,您将无法合并它们。
  • 如果存储库需要具有写入或管理员权限的人员批准审查,则具有这些权限的人员的任何审批都用绿色复选标记表示,而不具备这些权限的人员的审批带有灰色复选标记。 带有灰色复选标记的审批不会影响拉取请求是否可以合并。
  • 拉取请求作者无法批准自己的拉取请求。

Further reading