我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

此版本的 GitHub Enterprise 将停止服务 此版本的 GitHub Enterprise 已停止服务 2020-05-23. 即使针对重大安全问题,也不会发布补丁。 要获得更好的性能、改进的安全性和新功能,请升级到 GitHub Enterprise 的最新版本。 如需升级方面的帮助,请联系 GitHub Enterprise 支持

文章版本: Enterprise Server 2.17

本地检查拉取请求

When someone sends you a pull request from a fork or branch of your repository, you can merge it locally to resolve a merge conflict or to test and verify the changes before merging on GitHub Enterprise.

Anyone with write access to a repository can pull a remote pull request down locally.

本文内容

Note: Pull request authors can give upstream repository maintainers, or those with push access to the upstream repository, permission to make commits to their pull request's compare branch in a user-owned fork. 更多信息请参阅“允许更改从复刻创建的拉取请求分支”。

在本地修改活动的拉取请求

  1. 在仓库名称下,单击 Pull requests(拉取请求)
    议题和拉取请求选项卡选择
    1. 在拉取请求列表中,单击要合并的拉取请求。
  2. In the merge box, click command line instructions. 按照步骤顺序解决提议的拉取请求。
    访问命令行拉取请求说明的链接
  3. Optionally, to view proposed changes in GitHub Desktop, click open this in GitHub Desktop.
    在 Desktop 中本地打开拉取请求的链接

在本地修改非活动拉取请求

If a pull request's author is unresponsive to requests or has deleted their fork, the pull request can still be merged. 但是,如果您要对拉取请求进行更改,而其作者又没有响应,则需要执行一些额外步骤来更新拉取请求。

Once a pull request is opened, GitHub Enterprise stores all of the changes remotely. In other words, commits in a pull request are available in a repository even before the pull request is merged. You can fetch an open pull request and recreate it as your own.

任何人都可以处理先前打开的拉取请求,以继续处理它、测试它,甚至进行一些额外更改后作为新的拉取请求打开它。 但是,只有具有推送权限的协作者才能合并拉取请求。

  1. 在仓库名称下,单击 Issues(议题) Pull requests(拉取请求)
    议题和拉取请求选项卡选择
  2. 在“Pull Requests(拉取请求)”列表中,单击要合并的拉取请求。
  3. 找到非活动拉取请求的 ID 号。 这是拉取请求标题后面的数字序列。
    Pull Requests ID number
  4. 打开 Terminal(终端)Terminal(终端)Git Bash
  5. 根据其 ID 号获取对该拉取请求的引用,在该过程中创建一个新分支。
    $ git fetch origin pull/ID/head:BRANCHNAME
  6. Switch to the new branch that's based on this pull request:
    [master] $ git checkout BRANCHNAME
    > Switched to a new branch 'BRANCHNAME'
  7. 现在,您可以使用此分支执行任何操作。 You can run some local tests, or merge other branches into it, including master.
  8. When you're ready, you can push the new branch up:
    [pull-inactive-pull-request] $ git push origin BRANCHNAME
    > Counting objects: 32, done.
    > Delta compression using up to 8 threads.
    > Compressing objects: 100% (26/26), done.
    > Writing objects: 100% (29/29), 74.94 KiB | 0 bytes/s, done.
    > Total 29 (delta 8), reused 0 (delta 0)
    > To https://主机名/username/repository.git
    >  * [new branch]      BRANCHNAME -> BRANCHNAME
  9. Create a new pull request with your new branch.

Error: Failed to push some refs

The remote refs/pull/ namespace is read-only. If you try to push any commits there, you'll see this error:

! [remote rejected] HEAD -> refs/pull/1/head (deny updating a hidden ref)
error: failed to push some refs to 'git@github.local:USERNAME/REPOSITORY.git'

提示:删除或重命名远程引用时,本地 refs/pull/origin/ 命名空间将不会受到调用 git-remote 的影响。

问问别人

找不到要找的内容?

联系我们