我想检查之前创建的拉请求(通过GitHub web界面创建)。我搜索了一下,发现不同的地方有裁判/拉或裁判/拉/pr
但是当我添加fetch = +refs/pull/*/head:refs/remotes/origin/pr/*到git配置文件并进行git取回时
我哪里做错了?GitHub应该自动创建拉/xyz东西,还是我必须配置一些东西?
我想检查之前创建的拉请求(通过GitHub web界面创建)。我搜索了一下,发现不同的地方有裁判/拉或裁判/拉/pr
但是当我添加fetch = +refs/pull/*/head:refs/remotes/origin/pr/*到git配置文件并进行git取回时
我哪里做错了?GitHub应该自动创建拉/xyz东西,还是我必须配置一些东西?
当前回答
Github最近发布了一个名为Github -cli的cli实用程序。在安装它之后,你可以使用它的id (doc)在本地签出一个拉请求的分支。
例:gh pr checkout 2267
这也适用于fork,但如果你需要回推到fork,你需要添加远程存储库并使用传统的git推送(直到这个票据在gh实用程序中实现)
其他回答
Github最近发布了一个名为Github -cli的cli实用程序。在安装它之后,你可以使用它的id (doc)在本地签出一个拉请求的分支。
例:gh pr checkout 2267
这也适用于fork,但如果你需要回推到fork,你需要添加远程存储库并使用传统的git推送(直到这个票据在gh实用程序中实现)
对于Bitbucket,你需要将pull替换为pull-requests。
首先,你可以通过git ls-remote origin命令确认pull request URL样式。
$ git ls-remote origin |grep pull
f3f40f2ca9509368c959b0b13729dc0ae2fbf2ae refs/pull-requests/1503/from
da4666bd91eabcc6f2c214e0bbd99d543d94767e refs/pull-requests/1503/merge
...
正如你所看到的,它是refs/pull-requests/1503/from而不是refs/pull/1503/from
然后你可以使用任何答案的命令。
有一种使用git-cli的简单方法
gh pr checkout {<number> | <url> | <branch>}
参考:https://cli.github.com/manual/gh_pr_checkout
在更新版本的Git中:
Git fetch origin refs/pull-requests/<id>/from:<localbranchname>
如果你遵循“github fork”工作流,在这里你创建了一个fork并添加了远程上游回购:
14:47 $ git remote -v
origin git@github.com:<yourname>/<repo_name>.git (fetch)
origin git@github.com:<yourname>/<repo_name>.git (push)
upstream git@github.com:<repo_owrer>/<repo_name>.git (fetch)
upstream git@github.com:<repo_owner>/<repo_name>.git (push)
要拉入当前分支,你的命令看起来像这样:
git pull upstream pull/<pull_request_number>/head
要拉入一个新的分支,代码看起来像这样:
git fetch upstream pull/<pull_request_number>/head:newbranch