# 使用 GitHub Copilot 浏览拉取请求

GitHub Copilot 聊天功能 可以帮助你了解拉取请求的内容、功能和状态。

## 简介

你可以在拉取请求中的不同视图下，向 Copilot 提出有关该拉取请求的不同问题。 例如，可以要求 Copilot 汇总拉取请求，或解释拉取请求中特定文件或代码行内发生哪些更改。

## 获取拉取请求摘要

可以请求 Copilot 汇总拉取请求，或提供有关拉取请求状态的信息。

1. 在 GitHub 上，转到存储库中的拉取请求。

2. 在页面右上角，单击Copilot图标（**<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-copilot" aria-label="Copilot icon" role="img"><path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path></svg>**）打开副驾驶聊天。

Copilot 将把拉取请求用作你的问题的上下文。

1. 在面板底部 副驾驶聊天 的提示框中，键入问题，然后按 <kbd>Enter</kbd>。

### 示例提示

以下提示展示了你可以向 Copilot 提出的此类问题示例，可帮助你了解有关拉取请求的信息。

* `Summarize this pull request`
* `What is the current status of this pull request?`
* `What are the main changes in this pull request?`

## 让 Copilot 解释拉取请求中的更改

可以要求 Copilot 检查拉取请求中的更改并提供见解。               Copilot 可以利用拉取请求中的文件更改、提交、评论以及现有审查意见作为上下文，返回提交摘要、未解决的反馈列表，或者为你提供结构化的审查帮助，其中包含见解和可操作的建议。

1. 在 GitHub 上，转到存储库中的拉取请求。
2. 打开 副驾驶聊天，键入问题，然后按 <kbd>Enter</kbd>。

### 示例提示

* `Help me understand the commits made in this pull request.`
* `Is there any unresolved feedback in this pull request?`
* `Help review this pull request.`

## 询问对拉取请求中特定文件的更改

可以要求 Copilot 说明对拉取请求中特定文件所做的更改，或提供有关拉取请求中文件状态的信息。

1. 在 GitHub 上，转到存储库中的拉取请求。
2. 单击“已更改的文件”**选项卡。**
3. 在要询问的文件的行右侧，单击 <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-triangle-down" aria-label="Show file actions" role="img"><path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg> 图标，然后单击 **<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-copilot" aria-label="copilot" role="img"><path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path></svg>Copilot**，然后选择“ **询问此差异**”。

   这会打开 副驾驶聊天，文件更改会被标示为你的问题的上下文。

   你的对话会与差异并排显示，因此你可以同时查看代码并进行聊天。
4. 在聊天面板底部的提示框中，键入问题，然后按 <kbd>Enter</kbd>。

### 示例提示

* `What are the changes in this file?`
* `What is the status of this file in the pull request?`

## 在拉取请求中询问有关文件中特定行的问题

可以请求 Copilot 说明拉取请求中的特定代码行，或提供有关这些行的状态的信息。

1. 在 GitHub 上，转到存储库中的拉取请求。
2. 单击“已更改的文件”**选项卡。**
3. 单击要选择的第一行的行号，按住 <kbd>Shift</kbd> 并单击要选择的最后一行的行号。
4. 在所选行的右侧，单击 <svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-triangle-down" aria-label="Show file actions" role="img"><path d="m4.427 7.427 3.396 3.396a.25.25 0 0 0 .354 0l3.396-3.396A.25.25 0 0 0 11.396 7H4.604a.25.25 0 0 0-.177.427Z"></path></svg> 图标，然后单击 **<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-copilot" aria-label="copilot" role="img"><path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path></svg>Copilot**，然后选择“ **询问此差异**”。

   这将打开 副驾驶聊天，并将所选行作为你问题的上下文。
5. 在聊天面板底部的提示框中，键入问题，然后按 <kbd>Enter</kbd>。

### 示例提示

* `Explain the selected lines of code`
* `What do these lines of code do?`

## 询问工作流失败的原因

可以要求 Copilot 解释为什么工作流在拉取请求中失败，并提供有关如何解决问题的建议。

1. 在 GitHub 上，转到存储库中的拉取请求。

2. 滚动到页面底部，然后在其中一个失败的检查旁边单击省略号，然后单击“ **<svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-copilot" aria-label="copilot" role="img"><path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path></svg> 解释”错误。**

   这会打开 副驾驶聊天，工作流失败信息会被标示为你的问题的上下文，并且聊天输入框中会预填一个提示。
   Copilot 返回有关拉取请求失败原因的信息。
   Copilot 还可以提供有关如何解决问题的建议。

3. 如果 Copilot 提供了解决问题的步骤，可以按照以下步骤解决问题。

### 示例提示

* `Why has this workflow failed?`
* `What can I do to fix this issue?`

## 询问由 Copilot 创建的拉取请求的相关问题

查看由 Copilot云代理 创建的拉取请求时，你可以询问 Copilot 它完成了哪些工作。
Copilot 检索代理的会话日志，以说明更改的内容、已验证的内容以及原因。

### 示例提示

* `What did Copilot change in this pull request and why?`
* `What did Copilot validate before opening this pull request?`
* `Summarize the agent session that created this pull request.`

## 其他阅读材料

* [使用 GitHub Copilot 探索基本代码](/zh/enterprise-cloud@latest/copilot/tutorials/explore-a-codebase)
* [使用 GitHub Copilot 加速您公司的拉取请求](/zh/enterprise-cloud@latest/copilot/tutorials/roll-out-at-scale/drive-downstream-impact/accelerate-pull-requests)