Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将GitHub pull请求的旧版本视为远程分支_Git_Github_Pull Request_Git Remote - Fatal编程技术网

将GitHub pull请求的旧版本视为远程分支

将GitHub pull请求的旧版本视为远程分支,git,github,pull-request,git-remote,Git,Github,Pull Request,Git Remote,我正在从事一个用Git维护的项目,在GitHub上有一个中央存储库。我经常在本地副本的帮助下查看pull请求。虽然Git本身对“拉请求”一无所知,但GitHub在单独的分支名称空间中提供了这些信息。我已将Git配置为使用如下配置获取请求: [remote "origin"] url = git@github.com:octocat/hello-world.git fetch = +refs/heads/*:refs/remotes/origin fet

我正在从事一个用Git维护的项目,在GitHub上有一个中央存储库。我经常在本地副本的帮助下查看pull请求。虽然Git本身对“拉请求”一无所知,但GitHub在单独的分支名称空间中提供了这些信息。我已将Git配置为使用如下配置获取请求:

[remote "origin"]
    url = git@github.com:octocat/hello-world.git
    fetch = +refs/heads/*:refs/remotes/origin
    fetch = +refs/pull/*/head:refs/remotes/origin/pull/head/*
然后我可以使用
git checkout origin/pull/head/42
检查PR#42。到目前为止还不错

如果在我的初始审查之后强制推送了一个请求,我通常希望将我审查的版本与新版本进行比较。我希望有类似于
origin/pull/head/42/1
指第一次强制推之前的最新提交,
origin/pull/head/42/2
指第二次强制推之前的最新提交,等等(我不介意确切的名称)。有什么方法可以做到这一点吗

问题分为两部分:

  • 让GitHub告诉我pull请求的pre-force push提示的提交ID是什么。此信息显示在网页上(
    https://github.com/octocal/hello-world/pull/42
    说“…强制将
    mybranch
    分支从COMMIT1推到COMMIT2”),但我在列表中找不到它
  • 教导Git某个提交应该与某个远程分支名称一起出现,这可能是琐碎的,也可能不是琐碎的,这取决于(1)是如何完成的
  • 是否有一个配置或帮助程序可以让我轻松访问GitHub pull请求的旧版本,而无需从网页复制粘贴提交ID并为其提供本地分支名称?

    有一个,它列出了在repo上发生的操作,并返回事件:

    • 每个事件都有一个:
      PushEvent
      PullRequestEvent
      CreateEvent

    • 和有效载荷,这取决于其类型;例如:

      • 飞机的有效载荷
      • 飞机的有效载荷

    使用本地数据的部分答案:您的本地引用也记录在
    reflog
    中,您还可以查看您在
    git reflog origin/pull/head/42
    中的内容


    显然:该解决方案的局限性在于,您只能看到在本地repo上运行
    git fetch
    更新该引用的点;如果有人在您的两个
    git fetch
    之间强制推送了3次,您的本地reflog将不会更新3次。

    我认为您无法从GitHub以适当的机器可消化形式获取信息。你可以把它从网页上刮下来。一旦你获得了信息,使用它的唯一方法就是在
    获取
    行中大惊小怪:不要输入一个通用的“获取所有PR”,输入一个特定的“使用此本地名称获取此PR”,每个PR每次迭代。不是很漂亮,但应该很好用。