Skip to main content

此版本的 GitHub Enterprise 已停止服务 2022-10-12. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

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

  4. Optionally, filter the files to show only the files you want to review. 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

Reviewing dependency changes

注意:依赖项评审目前以 beta 版本提供,并且可能会发生更改。

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