Skip to main content

Asking Copilot to create a pull request

You can use a Copilot Chat prompt to ask Copilot to create a pull request.

谁可以使用此功能?

Copilot 编码智能体 可供 GitHub Copilot Pro+ 用户和 GitHub Copilot Enterprise 客户使用。 我们还开始向 GitHub Copilot Business 客户推出,一旦此功能可供你使用,你将收到一封电子邮件。
Sign up for Copilot

注意

  • If you have access to Copilot 编码智能体, you can create a pull request from Copilot Chat in Visual Studio Code, Visual Studio, JetBrains IDEs, and on GitHub.com.
  • Copilot 编码智能体 为 公共预览版,可能会变动。 在预览期间,该功能的使用须遵循“GitHub 预发行许可条款”。

Introduction

Often, when you are working on a project, you might notice a change you want to make, but the change doesn't directly relate to your current task. You might raise a GitHub issue to record that a change needs to be made—or perhaps, forget the change and move on.

Instead—if Copilot 编码智能体 is available—you can ask Copilot to make the change for you. Copilot will start working on the change in the background and, when it's done, request you to review the pull request it raises.

For information on making Copilot 编码智能体 available, see Enabling Copilot coding agent.

Creating a pull request from Copilot Chat

  1. Open GitHub Copilot Chat, in your IDE, or while viewing a file on GitHub.com.

  2. Type a prompt asking Copilot to create a pull request, and giving details of what you want Copilot to change.

    For example, @github Create a PR to put backticks around file names and variables in output.

    重要

    在 VS Code、Visual Studio 和 JetBrains IDE 中,必须在提示中提及 @github 聊天参与者。 可以在 GitHub.com 上的 Copilot Chat 中省略此项。

    提示

    To help Copilot, you can select the relevant line(s) of code before submitting your prompt.

  3. Submit your prompt.

    Copilot asks you to confirm that you want to use the coding agent to create a pull request.

  4. Click Allow.

    Copilot will respond with a link to the pull request it creates. It will work on the task and push changes to the pull request, and then add you as a reviewer when it has finished, triggering a notification.

Monitoring progress

You can see what Copilot is doing while it is working on a task by viewing the session logs. See Using the Copilot coding agent logs.

You can also stop Copilot from working on a task by clicking Stop session in the session logs.

Further reading