Skip to main content

Creating a pull request from a fork

Create a pull request from a fork to propose changes to an upstream repository and collaborate on code effectively.

谁可以使用此功能?

Anyone with write access to a repository can create a pull request from a user-owned fork. 具有托管用户的企业 成员只能对其企业一部分的存储库提出更改。

Before creating a pull request from a fork, fork the upstream repository and push your changes to a branch in your fork. See 为存储库创建分支.

In a pull request from a fork, the base branch is where you want to merge your changes, and the compare branch is the branch in your fork that contains your changes. See 创建拉取请求.

注意

要在公共存储库中打开拉取请求,你必须具有对头分支或源分支写入权限;对于组织拥有的仓库,你必须是拥有该存储库的组织的成员才能打开拉取请求。

  1. Navigate to the original repository where you created your fork.

  2. 在文件列表上方的黄色横幅中,单击“比较和拉取请求”****,为关联的分支创建拉取请求。

    文件列表上方横幅的屏幕截图。

  3. On the page to create a new pull request, click compare across forks.

    Screenshot of the page to open a pull request. The "compare across forks" link is outlined in dark orange.

  4. In the "base branch" dropdown menu, select the branch of the upstream repository where you want to merge changes.

    Screenshot of the page to open a new pull request. The dropdown menus for choosing the base repository and branch are outlined in dark orange.

  5. In the "head fork" dropdown menu, select your fork. Then, use the "compare branch" dropdown menu to select the branch where you made your changes.

    Screenshot of the page to open a new pull request. The dropdown menus for choosing the head repository and compare branch are outlined in dark orange.

  6. 为您的拉取请求输标题和说明。

  7. 在用户拥有的分支中,如果你希望允许对上游存储库具有推送访问权限的任何人更改你的拉取请求,请选择“允许维护员编辑”。

    警告

    如果你的分支包含 GitHub Actions 工作流,则选项是“Allow edits and access to secrets by maintainers”****。 允许对包含 GitHub Actions 工作流程的复刻分支进行编辑,也会允许维护员编辑复刻的仓库的工作流程,从而可能暴露密码值并允许访问其他分支。

  8. 要创建可供审查的拉取请求,请单击“创建拉取请求”。 若要创建草稿拉取请求,请使用下拉列表并选择“创建草稿拉取请求”,然后单击“草稿拉取请求” 。 如果你是组织的成员,则可能需要从组织所有者请求对草稿拉取请求的访问权限。 请参阅“拉取请求”。

提示

创建拉取请求后,你可请求特定人员审查你提议的更改。 有关详细信息,请参阅“请求拉取请求审查”。

Further reading