GitHub是否支持Git Wire协议v2?

7

GitLab 11.4(2018年11月)将支持HTTPS。请参见我下面编辑过的答案。 - VonC
1
GitHub已经在11月8日之前支持了Git wire协议V2,比GitLab稍早。请参见我下面编辑过的答案。 - VonC
2个回答

6
Not yet 自2018年11月起支持(请参见下面的最后一节)。我在“Git的传输协议是如何工作的”中介绍了协议v2,该协议在提交9bfa0f9中引入。

但这个新实现仅适用于Git 2.18,该版本于2018年7月发布。
在OP提出问题时,GitHub还不支持它。

您可以使用以下命令进行检查:

# Linux
GIT_CURL_VERBOSE=2 git -c protocol.version=2 ls-remote --heads https://github.com/bower/bower.git

# Windows:
cmd /v /c "set GIT_CURL_VERBOSE=2&& git -c protocol.version=2 ls-remote --heads https://github.com/bower/bower.git"

一个v2服务器会回复:
S: 200 OK
S: <Some headers>
S: ...
S:
S: 000eversion 2\n
S: <capability-advertisement>

七月份,我看到:

< HTTP/1.1 200 OK
< Server: GitHub Babel 2.0
< Content-Type: application/x-git-upload-pack-advertisement
< Transfer-Encoding: chunked
< Expires: Fri, 01 Jan 1980 00:00:00 GMT
< Pragma: no-cache
< Cache-Control: no-cache, max-age=0, must-revalidate
< Vary: Accept-Encoding
< X-GitHub-Request-Id: F361:7598:2BF8FEF:518E5FB:5B541C22
< X-Frame-Options: DENY

目前还没有 000eversion 2\n 版本。


注意:(2018年7月),GitLab的方向页面清楚地提到了“支持Git协议版本2”的GitLab 11.2(2018年8月22日):请参见问题46555

为了使GitLab服务器开始使用v2协议回答,我们需要做一些事情:

  • (必需)在gitlab-omnibus中的Gitaly服务器上安装Git 2.18
  • (必需)在workhorse -> gitaly -> git中传播Git-Protocol HTTP头,请参见gitlab-org/gitaly-proto合并请求208
  • (必需)在sshd -> gitlab-shell -> gitaly -> git中传播Git-Protocol环境变量
  • (可选)使用功能标志门控v2广告,以便我们可以阻止它达到gitaly。这样,我们就可以控制v2协议是否处于活动状态。

谁会是第一个?


... 从这个评论中,GitLab可能会首先支持(2018年11月,对于GitLab 11.4

看起来我们是第一个支持它的大型Git主机!如果我们验证了这一点,我们应该在发布博客文章中提到它 :)

但目前只有HTTPS,还没有SSH(问题46555

SSH上的Git v2也不会默认启用(需要SSHD更改,我们需要记录)。

问题5244证实:

我可以看到在GitLab.com上通过HTTP工作

# Original Git wire protocol
GIT_TRACE_PACKET=1 git -c protocol.version=0 ls-remote https://gitlab.com/gitlab-org/gitlab-ce.git master

# New Git wire protocol v2
GIT_TRACE_PACKET=1 git -c protocol.version=2 ls-remote https://gitlab.com/gitlab-org/gitlab-ce.git master

文档应遵循(gitlab-org/gitlab-ce合并请求22227)。


... 然而,GitLab相对于GitHub来说稍微有点晚:

11月8日: "GitHub上支持Git Wire Protocol v2":

GitHub now supports version 2 of the Git wire protocol.

An immediate benefit of the new protocol is that it enables reference filtering on the server-side, this can reduce the number of bytes required to fulfill operations like **git fetch on large repositories**. (source, source, source, …)

To utilize the new protocol, your git client must be at or beyond version 2.18, released June 2018 and the protocol version must be specified in your git client configuration:

git config --global protocol.version 2
请参阅 "Documentation/technical/protocol-v2.txt" 了解更多信息。

@user2935600 确实:那看起来像是一个一位偏差错误(OBOE)。 - VonC
@user2935600,正确的是:缺少2,因此不是OBOE。这是在9个月前引入的,在v2之前:https://github.com/git/git/commit/373d70efb2278b76739d8c6538d4a4e59cc81bf7 - VonC
@VonC,现在GitLab.com上已经可以使用(目前仅支持HTTP)。它将在GitLab 11.4版本中发布(支持SSH/HTTP)。 - BLuEGoD
@BLuEGoD 谢谢。我已经将您的评论包含在答案中,以增加其可见性,并附加了一些链接。 - VonC
显示剩余4条评论


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接