【问题标题】:Does github support git wire protocol v2?github 是否支持 git Wire 协议 v2?
【发布时间】:2018-07-22 04:39:00
【问题描述】:

【问题讨论】:

  • GitLab 11.4(2018 年 11 月)将支持它,用于 HTTPS。请参阅下面我编辑的答案。
  • 截至 11 月 8 日,GitHub 已经支持 Git 有线协议 V2,略早于 GitLab。请参阅下面我编辑的答案。

标签: git github


【解决方案1】:

还没有 是,自 2018 年 11 月起(请参阅下面的最后一部分)。
我在“How does Git's transfer protocol work”中介绍了协议 v2,在commit 9bfa0f9 中介绍。

但这个新的实现仅可追溯到 2018 年 7 月发布的 Git 2.18。
在 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 月),direction page of GitLab 明确提到了 GitLab 11.2(2018 年 8 月 22 日)的“支持 Git 协议版本 2”:请参阅 issue 46555

为了让 GitLab 服务器开始使用 v2 协议进行响应,我们需要做一些事情:

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

谁会是第一个?


...From this comment,GitLab 可能是第一个(2018 年 11 月,对于 GitLab 11.4

看起来我们是第一个支持此功能的大型 Git 主机!我们应该确保在发布的博客文章中提到,如果我们验证确实如此:)

但目前只有 HTTPS,还没有 SSH (issue 46555)

默认情况下也不会启用基于 SSH 的 Git v2(需要更改 SSHD,我们需要对此进行记录)。

Issue 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 merge-request 22227)


...然而 GitLab 迟到了 GitHub:

十一月第八名:“Git Wire Protocol v2 Support on GitHub”:

GitHub 现在支持第 2 版 Git 有线协议。

新协议的一个直接好处是它可以在服务器端启用引用过滤,这可以减少在大型存储库上完成诸如 **git fetch 之类的操作所需的字节数** . (source, source, source, ...)

要使用新协议,您的 git 客户端必须是 2018 年 6 月发布的版本 2.18 或更高版本,并且必须在您的 git 客户端配置中指定协议版本:

git config --global protocol.version 2

请参阅“Documentation/technical/protocol-v2.txt”了解更多信息。

【讨论】:

  • 非常感谢您的验证步骤。顺便说一句,鉴于您对新协议的广泛背景,您可能应该邮寄一个补丁来更新[protocol.version] (git-scm.com/docs/git-config#git-config-protocolversion) 的文档,其中包含有关新有线协议的信息。
  • @user2935600 是的:这看起来像是一个错误(OBOE)。
  • 是吗?可能这就是为什么我找不到协议版本 1 的文档:P
  • @user2935600 正确:缺少 2,因此不是 OBOE。这是 9 个月前推出的,在 v2 之前:github.com/git/git/commit/…
  • @user2935600 找到了! marc.info/?l=git&m=152702833511253&w=2(尚未包含在 master 中)
【解决方案2】:
猜你喜欢
  • 1970-01-01
  • 2021-10-10
  • 2017-12-25
  • 2012-07-09
  • 2014-11-08
  • 1970-01-01
  • 1970-01-01
  • 2013-02-18
  • 2019-03-27
相关资源
最近更新 更多