Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does github support git wire protocol v2?

Tags:

git

github

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

like image 818
kunjbhai Avatar asked Jul 22 '18 04:07

kunjbhai


People also ask

What is v2 protocol?

Protocol version 2 is stateless by default. This means that all commands must only last a single round and be stateless from the perspective of the server side, unless the client has requested a capability indicating that state should be maintained by the server.

What is git protocol?

The git protocol is a special daemon that comes packaged with Git; it listens on a dedicated port (9418) that provides a service similar to the SSH protocol, but with absolutely no authentication. It was introduced at the very beginning of Git, in commit 2386d65 (July 2005, Git 0.99.1)

How do I change my git protocol?

You can change remote url to http protocol using: git remote set-url origin http://new.git.url/here . Documentation. Yes, you can do that per repo.


2 Answers

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.

like image 141
VonC Avatar answered Nov 15 '22 08:11

VonC


It happened :)

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

like image 33
ulrichb Avatar answered Nov 15 '22 08:11

ulrichb