有时,我登录到云实例,拉一个回购,然后想尝试一个拉请求。我现在使用的命令是
git fetch origin pull/<ID>/head && git checkout FETCH_HEAD这是很长的。我也尝试了更短的方法
git reset --hard origin/pull/<ID>
git reset --hard origin/pull/<ID>/head
git reset --hard origin/pull/<ID>/HEAD给出以下错误
$ git reset --hard origin/pull/27
fatal: ambiguous argument 'origin/pull/27': unknown revision
or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'为什么git reset --hard origin/<some-branch>工作,而不是拉请求分支?
我注意到在…的输出中
$ git ls-remote origin规则分支和拉请求分支之间有区别。例如
c31a55参/头/fix-异步-标准输出顺序 615 f5a参参/拉/10/头
heads和pull有什么不同?(我在这里缩短了哈希,使它在视觉上更干净)
发布于 2019-03-05 05:44:31
GitHub建议:git fetch origin pull/ID/head:BRANCHNAME:这样您就可以控制本地分支的命名约定,而不是创建(由于PR的GitHub上默认的重构规范)。
但你有更先进的技术
[alias]
copr = "!f() { git fetch -fu ${2:-origin} refs/pull/$1/head:pr/$1 &&
git checkout pr/$1; }; f"然后:
$ git copr 1234 # gets and switches to pr/1234 from origin
$ git copr 789 upstream # gets and switches to pr/789 from upstream网络中心也以包装PR导入而闻名。
https://stackoverflow.com/questions/54996024
复制相似问题