BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News Git 2.26 Makes Protocol Version 2 the Default

Git 2.26 Makes Protocol Version 2 the Default

This item in japanese

Introduced in Git 2.18, Git wire protocol version 2 is now used by default in Git's latest version, 2.26. Git 2.26 also improves configuration option handling and sparse-checkouts, among other things.

Git’s wire protocol defines how Git clients and servers communicate with each other. The new Git protocol version improves performance by enabling server-side filtering of references, which include not only branches and tags but also, e.g., pull request heads and others. Clients adopting Git protocol version 2 will be able to specify which references they are interested in, thus reducing the amount of data the server sends back. Contrast this with Git's original protocol behaviour, where the server starts by sending back a list of all references in the repository, which could amount to many megabytes.

According to figures provided by Google engineer Brandon Williams at the time of the Git protocol version 2 announcement, the new protocol can be significantly faster than the old one, especially with large repositories such as Chrome's, which contains more than 500k references. Additionally, noted Williams,

Protocol v2 has also enabled a reduction of 8x of the overhead bytes (non-packfile) sent from googlesource.com servers. A majority of this improvement is due to filtering references advertised by the server to the refs the client has expressed interest in.

The reason for the delay in making Git protocol version 2 the default, notes Taylor Blau on GitHub blog, has been giving enough time for developers to catch any bugs in the protocol implementation. Interestingly, Git protocol version 2 is designed so any client implementing it can still talk to a Git server only supporting the old Git protocol.

As usual for Git releases, Git 2.26 includes a very long list of performance improvements, fixes, and new features. For example, git clone --recurse-submodules --single-branch now applies the --single-branch option to submodules as well.

Additionally, the git sparse-checkout command, introduced in Git 2.25, has a new add subcommand which can be used to add new directories to your sparse checkout one at a time. Sparse checkouts are mostly useful with large repositories, where you are not interested in the whole repo content but only on some of its subdirectories. In Git 2.25, to add a new directory to those already included in your sparse checkout, you were required to list all of them when using the set subcommand.

Worth a mention is also the improvement to the diff family of commands, which enables git add -p to better deal with whitespace problems.

As a final note, Git 2.26 makes it easier for you to know where one default option is defined, whether at repository, user, or system level, using git config --show-origin.

Do not miss Git 2.26 official release notes if you are interested in the full details about this release.

Rate this Article

Adoption
Style

BT