我在github上有一个拉取请求的列表。我可以像这样获取拉取请求:
git fetch origin +refs/pull/*:refs/remotes/origin/pr/*我得到的输出如下:
* [new ref] refs/pull/1/head -> origin/pr/1/head
* [new ref] refs/pull/1/merge -> origin/pr/1/merge
* [new ref] refs/pull/10/head -> origin/pr/10/head
* [new ref] refs/pull/10/merge -> origin/pr/10/merge
* [new ref] refs/pull/11/head -> origin/pr/11/head
* [new ref] refs/pull/11/merge -> origin/pr/11/merge现在我想看看这些裁判中的一个。我尝试过的似乎都不管用:
$ git checkout refs/pull/1/head
error: pathspec 'refs/pull/1/head' did not match any file(s) known to git.或者:
git checkout origin/pr/1/head
error: pathspec 'origin/pr/1/head' did not match any file(s) known to git.如何查看此参考资料?
发布于 2012-11-30 11:37:03
第一个命令(git checkout refs/pull/1/head)不起作用,因为refs/pull/1/head是远程存储库中引用的名称。您的本地存储库中没有该名称的引用,因为您的fetch refspec将其转换为refs/remotes/origin/pr/1/head。
第二个命令(git checkout origin/pr/1/head)应该可以工作,尽管它应该给您一个"detached HEAD“警告。在将问题发布到Stack Overflow时,您是否修复了拼写错误?
您的fetch refspec告诉git在refs/remotes目录中将远程引用转换为本地引用。该目录中的引用被特殊处理--它们是“远程引用”,用于指示上次执行fetch时远程存储库的状态。通常,您不希望直接签出这些引用--您希望创建一个配置为“跟踪”或“跟踪”远程引用的本地分支(这将启用特殊的方便快捷方式,如@{u}修订参数和更简单的push/pull使用)。
尝试:
git fetch origin +refs/pull/*:refs/remotes/origin/pr/*
git checkout -b whatever-branch-name-you-want origin/pr/1/head上面创建了一个名为whatever-branch-name-you-want (我建议将其称为pr/1/head)的新本地分支,指向与origin/pr/1/head相同的提交,配置whatever-branch-name-you-want以跟踪origin/pr/1/head,然后切换到新分支。
发布于 2012-11-30 10:43:33
查看可用于结帐的内容
git branch -ahttps://stackoverflow.com/questions/13638235
复制相似问题