How does Git wire protocol v2 improve fetch performance?
AdvancedConceptGitHub features, history rewriting and scale
Answer
Protocol v2 (default since Git 2.26) replaces the huge ref advertisement with a ls-refs command that accepts prefixes, so the client only lists refs it cares about. On repos with hundreds of thousands of refs this cuts the initial handshake dramatically. It is also the base for fetch filters and the object-format capability.
GIT_TRACE_PACKET=1 git ls-remote origin refs/heads/main 2>&1 | head
git -c protocol.version=2 fetch origin
More on GitHub features, history rewriting and scale
What does a GitHub Actions workflow look like at a basic level?BeginnerWhat are GitHub environments and what protection do they offer?IntermediateWhat is a GitHub Release and how does it relate to a Git tag?BeginnerWhat are the permissions of `GITHUB_TOKEN` and how do you restrict them?IntermediateWhy do fork PRs get no secrets, and what is `pull_request_target`?AdvancedWhat is the difference between a GitHub fork and a clone?Beginner