我想检查之前创建的拉请求(通过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东西,还是我必须配置一些东西?
当前回答
这个要点描述了当你进行git取回时发生了什么:
显然,改变github的url,以匹配你的项目的url。结果是这样的:
[remote "origin"]
url = git@github.com:joyent/node.git
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
fetch = +refs/heads/*:refs/remotes/origin/*
请注意fetch refspecs的顺序,正如crashneb在他自己的回答中所建议的那样。
如果不是,意思是如果你没有正确的顺序,因为:
Git添加remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"… 然后信任pr -checkout自然地设置了新的本地分支,使用类似git开关pr/1的东西——然后你可能会遇到麻烦,如果pr更新了,你想要git再次拉它。 branch.pr / 1。合并配置值不正确。
现在获取所有的pull请求: $ git获取原点 从github.com: joyent /节点 * [new ref] refs/pull/1000/head -> origin/pr/1000 * [new ref] refs/pull/1002/head -> origin/pr/1002 *[新ref] refs/pull/1004/head -> origin/pr/1004 *[新ref] refs/pull/1009/head -> origin/pr/1009 ... 检查一个特定的拉请求: $ git结账pr/999 分支pr/999设置跟踪远程分支pr/999从原点。 切换到新的分支“pr/999”
问题259中列出了各种脚本来自动化该任务。 git-extras项目提出了git-pr命令(在PR 262中实现)
git-pr(1)——在本地检出一个pull请求
SYNOPSIS git-pr <number> [<remote>] git-pr clean DESCRIPTION Creates a local branch based on a GitHub pull request number, and switch to that branch afterwards. The name of the remote to fetch from. Defaults to origin. EXAMPLES This checks out the pull request 226 from origin: $ git pr 226 remote: Counting objects: 12, done. remote: Compressing objects: 100% (9/9), done. remote: Total 12 (delta 3), reused 9 (delta 3) Unpacking objects: 100% (12/12), done. From https://github.com/visionmedia/git-extras * [new ref] refs/pull/226/head -> pr/226 Switched to branch 'pr/226'
其他回答
这个要点描述了当你进行git取回时发生了什么:
显然,改变github的url,以匹配你的项目的url。结果是这样的:
[remote "origin"]
url = git@github.com:joyent/node.git
fetch = +refs/pull/*/head:refs/remotes/origin/pr/*
fetch = +refs/heads/*:refs/remotes/origin/*
请注意fetch refspecs的顺序,正如crashneb在他自己的回答中所建议的那样。
如果不是,意思是如果你没有正确的顺序,因为:
Git添加remote.origin.fetch "+refs/pull/*/head:refs/remotes/origin/pr/*"… 然后信任pr -checkout自然地设置了新的本地分支,使用类似git开关pr/1的东西——然后你可能会遇到麻烦,如果pr更新了,你想要git再次拉它。 branch.pr / 1。合并配置值不正确。
现在获取所有的pull请求: $ git获取原点 从github.com: joyent /节点 * [new ref] refs/pull/1000/head -> origin/pr/1000 * [new ref] refs/pull/1002/head -> origin/pr/1002 *[新ref] refs/pull/1004/head -> origin/pr/1004 *[新ref] refs/pull/1009/head -> origin/pr/1009 ... 检查一个特定的拉请求: $ git结账pr/999 分支pr/999设置跟踪远程分支pr/999从原点。 切换到新的分支“pr/999”
问题259中列出了各种脚本来自动化该任务。 git-extras项目提出了git-pr命令(在PR 262中实现)
git-pr(1)——在本地检出一个pull请求
SYNOPSIS git-pr <number> [<remote>] git-pr clean DESCRIPTION Creates a local branch based on a GitHub pull request number, and switch to that branch afterwards. The name of the remote to fetch from. Defaults to origin. EXAMPLES This checks out the pull request 226 from origin: $ git pr 226 remote: Counting objects: 12, done. remote: Compressing objects: 100% (9/9), done. remote: Total 12 (delta 3), reused 9 (delta 3) Unpacking objects: 100% (12/12), done. From https://github.com/visionmedia/git-extras * [new ref] refs/pull/226/head -> pr/226 Switched to branch 'pr/226'
如果你使用Github.com,转到“拉请求”,点击相关的拉请求,然后点击“命令行说明”链接:
将远程公关分支机构导入本地分支机构:
Git获取来源' remote_branch ': ' local_branch_name '
配置本地分支的上游为远端分支。
git分支——set-upstream-to=origin/PR_Branch_Name local_branch
当您想再次将本地更改推到PR分支时
git push origin HEAD:remote_PR_Branch_name
创建本地分支
git checkout -b local-branch-name
拉遥控器PR
git pull git@github.com:your-repo-ssh.git remote-branch-name
如果你遵循“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