7

Just wanted to know whether github server supports git wire protocol-v2? - https://opensource.googleblog.com/2018/05/introducing-git-protocol-version-2.html - https://github.com/git/git/blob/master/Documentation/technical/protocol-v2.txt

kunjbhai
  • 323
  • 1
  • 9
  • GitLab 11.4 (Nov 2018) will support it, for HTTPS. See my edited answer below. – VonC Oct 11 '18 at 08:40
  • 1
    GitHub is already supporting Git wire protocol V2, slightly before GitLab, as of Nov. 8th. See my edited answer below. – VonC Nov 09 '18 at 15:56

2 Answers2

6

Not yet Yes since Nov. 2018 (see the last section below).
I have presented the protocol v2 in "How does Git's transfer protocol work", introduced in commit 9bfa0f9.

But this new implementation only dates from Git 2.18, released in July 2018.
It was too soon yet for GitHub to support it at the time of the OP's question.

You can check that with:

# 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"

A v2 server would reply:

S: 200 OK
S: <Some headers>
S: ...
S:
S: 000eversion 2\n
S: <capability-advertisement>

In July, I saw:

< 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

No 000eversion 2\n yet.


Note: (July 2018), the direction page of GitLab clearly mentions a "Support Git protocol version 2" for GitLab 11.2 (Aug. 22nd, 2018): see issue 46555.

In order for GitLab servers to start answering with the v2 protocol we need to do a few things:

  • (required) install Git 2.18 on Gitaly servers in gitlab-omnibus
  • (required) propagate the Git-Protocol HTTP header in workhorse -> gitaly -> git: see gitlab-org/gitaly-proto merge request 208
  • (required) propagate the Git-Protocol environment variable in sshd -> gitlab-shell -> gitaly -> git
  • (optional) gate the v2 advertisement with a feature flag so that we can stop it from reaching gitaly. That way we would be in control of whether the v2 protocol is active or not.

Who will be first?


... From this comment, GitLab might be first (Nov 2018, for GitLab 11.4)

it looks like we're the first big Git host to support this! We should be sure to mention that in the release blog post, if we verify it is indeed the case :)

But only HTTPS for now, not yet SSH (issue 46555)

Git v2 over SSH won't be enabled by default either (requires SSHD changes, which we'll need to document).

Issue 5244 confirms:

I can see that this is working via HTTP on GitLab.com

# 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

Documentation should follow (gitlab-org/gitlab-ce merge-request 22227)


... GitLab is however narrowly late to GitHub:

Nov. 8th: "Git Wire Protocol v2 Support on GitHub":

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

See "Documentation/technical/protocol-v2.txt" for more.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thanks a lot for the verification steps. Btw, given your extensive context on the new protocol, may be you should mail a patch to update documentation of `[protocol.version]` (https://git-scm.com/docs/git-config#git-config-protocolversion) with information regarding the new wire protocol. – kunjbhai Jul 23 '18 at 08:45
  • @user2935600 True: that looks like an off-by-one error (OBOE). – VonC Jul 23 '18 at 08:46
  • Is it? May be thats why I could not find documentation for protocol version 1 :P – kunjbhai Jul 23 '18 at 08:47
  • @user2935600 Right: 2 is missing, so not an OBOE. This was introduced 9 months ago, before v2: https://github.com/git/git/commit/373d70efb2278b76739d8c6538d4a4e59cc81bf7 – VonC Jul 23 '18 at 08:48
  • @user2935600 Found it! https://marc.info/?l=git&m=152702833511253&w=2 (not yet included to master) – VonC Jul 23 '18 at 08:50
  • The comment on the commit is the very reason I was apprehensive of submitting a patch myself: "Should this mention where the user can find more details " – kunjbhai Jul 23 '18 at 08:56
  • @user2935600 I think it should mention a link to the documentation indeed. – VonC Jul 23 '18 at 08:57
  • @VonC this is now available on GitLab.com (only HTTP is enabled for now). It will be released on GitLab 11.4 (SSH/HTTP). – BLuEGoD Oct 11 '18 at 07:36
  • @BLuEGoD Thank you. I have included your comment in the answer for more visibility, with some additional links. – VonC Oct 11 '18 at 08:36
2

It happened :)

"GitHub now supports version 2 of the Git wire protocol"

ulrichb
  • 19,610
  • 8
  • 73
  • 87