GITPROTOCOL-V2(5)
π NAME π
okay bestie, this is gitprotocol-v2 β the manual page for Git Wire Protocol, Version 2. yes, the whole wire-protocol-spec vibe, and it's lowkey iconic. π«Ά
β¨ SYNOPSIS β¨
it's giving:
<over-the-wire-protocol>
π¦ DESCRIPTION π¦
This document presents a specification for a version 2 of Gitβs wire protocol. Protocol v2 will improve upon v1 in the following ways:
- Instead of multiple service names, multiple commands will be supported by a single service
- Easily extendable as capabilities are moved into their own section of the protocol, no longer being hidden behind a NUL byte and limited by the size of a pkt-line
- Separate out other information hidden behind NUL bytes (e.g. agent string as a capability and symrefs can be requested using
ls-refs) - Reference advertisement will be omitted unless explicitly requested
ls-refscommand to explicitly request some refs- Designed with
httpandstateless-rpcin mind. With clear flush semantics thehttpremote helper can simply act as a proxy
In protocol v2 communication is command oriented. When first contacting a server a list of capabilities will be advertised. Some of these capabilities will be commands which a client can request be executed. Once a command has completed, a client can reuse the connection and request that other commands be executed.
π PACKET-LINE FRAMING π
All communication is done using packet-line framing, just as in v1. See gitprotocol-pack(5) and gitprotocol-common(5) for more information.
In protocol v2 these special packets will have the following semantics:
0000Flush Packet (flush-pkt) - indicates the end of a message0001Delimiter Packet (delim-pkt) - separates sections of a message0002Response End Packet (response-end-pkt) - indicates the end of a response for stateless connections
π INITIAL CLIENT REQUEST π
In general a client can request to speak protocol v2 by sending version=2 through the respective side-channel for the transport being used which inevitably sets GIT_PROTOCOL. More information can be found in gitprotocol-pack(5) and gitprotocol-http(5), as well as the GIT_PROTOCOL definition in git(1). In all cases the response from the server is the capability advertisement.
π Git Transport
When using the git:// transport, you can request to use protocol v2 by sending "version=2" as an extra parameter:
003egit-upload-pack /project.git\0host=myserver.com\0\0version=2\0
π SSH and File Transport
When using either the ssh:// or file:// transport, the GIT_PROTOCOL environment variable must be set explicitly to include "version=2". The server may need to be configured to allow this environment variable to pass.
π HTTP Transport
When using the http:// or https:// transport a client makes a "smart" info/refs request as described in gitprotocol-http(5) and requests that v2 be used by supplying "version=2" in the Git-Protocol header.
C: GET $GIT_URL/info/refs?service=git-upload-pack HTTP/1.0
C: Git-Protocol: version=2
A v2 server would reply:
S: 200 OK
S: <Some headers>
S: ...
S:
S: 000eversion 2\n
S: <capability-advertisement>
Subsequent requests are then made directly to the service $GIT_URL/git-upload-pack. (This works the same for git-receive-pack).
Uses the --http-backend-info-refs option to git-upload-pack(1).
The server may need to be configured to pass this headerβs contents via the GIT_PROTOCOL variable. See the discussion in git-http-backend(1).
π CAPABILITY ADVERTISEMENT π
A server which decides to communicate (based on a request from a client) using protocol version 2, notifies the client by sending a version string in its initial response followed by an advertisement of its capabilities. Each capability is a key with an optional value. Clients must ignore all unknown keys. Semantics of unknown values are left to the definition of each key. Some capabilities will describe commands which can be requested to be executed by the client.
capability-advertisement = protocol-version
capability-list
flush-pkt
protocol-version = PKT-LINE("version 2" LF)
capability-list = *capability
capability = PKT-LINE(key[=value] LF)
key = 1*(ALPHA | DIGIT | "-_")
value = 1*(ALPHA | DIGIT | " -_.,?\/{}[]()<>!@#$%^&*+=:;")
π COMMAND REQUEST π
After receiving the capability advertisement, a client can then issue a request to select the command it wants with any particular capabilities or arguments. There is then an optional section where the client can provide any command specific parameters or queries. Only a single command can be requested at a time.
request = empty-request | command-request
empty-request = flush-pkt
command-request = command
capability-list
delim-pkt
command-args
flush-pkt
command = PKT-LINE("command=" key LF)
command-args = *command-specific-arg
command-specific-args are packet line framed arguments defined by
each individual command.
The server will then check to ensure that the clientβs request is comprised of a valid command as well as valid capabilities which were advertised. If the request is valid the server will then execute the command. A server MUST wait till it has received the clientβs entire request before issuing a response. The format of the response is determined by the command being executed, but in all cases a flush-pkt indicates the end of the response.
When a command has finished, and the client has received the entire response from the server, a client can either request that another command be executed or can terminate the connection. A client may optionally send an empty request consisting of just a flush-pkt to indicate that no more requests will be made.
π§ CAPABILITIES π§
There are two different types of capabilities: normal capabilities, which can be used to convey information or alter the behavior of a request, and commands, which are the core actions that a client wants to perform (fetch, push, etc).
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. Clients MUST NOT require state management on the server side in order to function correctly. This permits simple round-robin load-balancing on the server side, without needing to worry about state management.
π€ agent
The server can advertise the agent capability with a value X (in the form agent=X) to notify the client that the server is running version X. The client may optionally send its own agent string by including the agent capability with a value Y (in the form agent=Y) in its request to the server (but it MUST NOT do so if the server did not advertise the agent capability). The X and Y strings may contain any printable ASCII characters except space (i.e., the byte range 33 β¨ x β¨ 126), and are typically of the form "package/version-os" (e.g., "git/1.8.3.1-Linux") where os is the operating system name (e.g., "Linux"). X and Y can be configured using the GIT_USER_AGENT environment variable and it takes priority. The os is retrieved using the sysname field of the uname(2) system call or its equivalent. The agent strings are purely informative for statistics and debugging purposes, and MUST NOT be used to programmatically assume the presence or absence of particular features.
π¦ ls-refs
ls-refs is the command used to request a reference advertisement in v2. Unlike the current reference advertisement, ls-refs takes in arguments which can be used to limit the refs sent from the server.
Additional features not supported in the base command will be advertised as the value of the command in the capability advertisement in the form of a space separated list of features: "<command>=<feature-1> <feature-2>"
ls-refs takes in the following arguments:
symrefsβ In addition to the object pointed by it, show the underlying ref pointed by it when showing a symbolic ref.peelβ Show peeled tags.ref-prefix <prefix>β When specified, only references having a prefix matching one of the provided prefixes are displayed. Multiple instances may be given, in which case references matching any prefix will be shown. Note that this is purely for optimization; a server MAY show refs not matching the prefix if it chooses, and clients should filter the result themselves.
If the unborn feature is advertised the following argument can be included in the clientβs request.
unbornβ The server will send information aboutHEADeven if it is a symref pointing to an unborn branch in the form"unborn HEAD symref-target:<target>".
The output of ls-refs is as follows:
output = *ref
flush-pkt
obj-id-or-unborn = (obj-id | "unborn")
ref = PKT-LINE(obj-id-or-unborn SP refname *(SP ref-attribute) LF)
ref-attribute = (symref | peeled)
symref = "symref-target:" symref-target
peeled = "peeled:" obj-id
π fetch
fetch is the command used to fetch a packfile in v2. It can be looked at as a modified version of the v1 fetch where the ref-advertisement is stripped out (since the ls-refs command fills that role) and the message format is tweaked to eliminate redundancies and permit easy addition of future extensions.
Additional features not supported in the base command will be advertised as the value of the command in the capability advertisement in the form of a space separated list of features: "<command>=<feature-1> <feature-2>"
A fetch request can take the following arguments:
want <oid>β Indicates to the server an object which the client wants to retrieve. Wants can be anything and are not limited to advertised objects.have <oid>β Indicates to the server an object which the client has locally. This allows the server to make a packfile which only contains the objects that the client needs. Multiplehavelines can be supplied.doneβ Indicates to the server that negotiation should terminate (or not even begin if performing a clone) and that the server should use the information supplied in the request to construct the packfile.thin-packβ ask the server to send a thin pack, i.e. one with deltas that point at base objects not in the pack (they're already known to exist on the receiving end π). It can cut network traffic a LOT, but the receiver has to know how to "thicken" those packs by adding the missing bases back in π§no-progressβ ask that progress info not be sent. Normally it'd go over side-band channel 2 during the packfile transfer, so this just turns that off π. Heads up though: side-band channel 3 is still used for error responses, no cap.include-tagβ request that annotated tags get sent if the objects they point to are being sent π·οΈofs-deltaβ signals that the client understands PACKv2 where deltas refer to their base by position in the pack instead of by an oid. Basically: they can readOBJ_OFS_DELTA(aka type 6) in a packfile β¨
If the shallow feature is advertised, these args can go in the client request too β and the server's response might get a shallow-info section added to it, as explained below π
shallow <oid>β the client has to tell the server about every commit it only has a shallow copy of (meaning it doesn't have that commit's parents π) by sending ashallow <oid>line for each one, so the server knows the limits of the client's history. That way the server is aware the client might not have all objects reachable from those commits.deepen <depth>β requests that the fetch/clone be shallow, with a commit depth of<depth>relative to the remote side πdeepen-relativeβ requests that the semantics ofdeepenchange: the depth requested becomes relative to the client's current shallow boundary instead of relative to the requested commits πdeepen-since <timestamp>β requests that the shallow clone/fetch be cut at a specific time rather than by depth. Internally it's the same as doinggit rev-list --max-age=<timestamp>β°. Cannot be used withdeepen.deepen-not <rev>β requests that the shallow clone/fetch be cut at a specific revision given by<rev>instead of by depth. Internally it's the same as doinggit rev-list --not <rev>βοΈ. Cannot be used withdeepen, but can be used withdeepen-since.
If the filter feature is advertised, this arg can go in the client's request:
filter <filter-spec>β request that various objects be left out of the packfile using one of several filtering techniques π. These are meant for partial clone and partial fetch operations. Seerev-listfor the possible"filter-spec"values. When talking to other processes, senders SHOULD translate scaled integers (e.g."1k") into a fully-expanded form (e.g."1024") to help interoperability with older receivers that might not understand newly-invented scaling suffixes. But receivers SHOULD accept these suffixes:k,m, andgfor 1024, 1048576, and 1073741824, respectively π
If the ref-in-want feature is advertised, this arg can go in the client's request too β and the server's response might gain a wanted-refs section, as explained below π
want-ref <ref>β tells the server the client wants a particular ref, where<ref>is the full name of a ref on the server π―. It is a protocol error to sendwant-reffor the same ref more than once. Not me double-texting the server π
If the sideband-all feature is advertised, this arg can go in the client's request:
sideband-allβ tells the server to send the whole response multiplexed, not just the packfile section π‘. Every non-flush and non-delim PKT-LINE in the response (not only in the packfile section) will then start with a byte indicating its sideband (1, 2, or 3), and the server may send"0005\2"(a PKT-LINE of sideband 2 with no payload) as a keepalive packet π«Ά
If the packfile-uris feature is advertised, this arg can go in the client's request too β and the server's response might gain a packfile-uris section, as explained below. Note that at most one packfile-uris line can be sent to the server π
packfile-uris <comma-separated-list-of-protocols>β tells the server the client is willing to receive URIs of any of the given protocols in place of objects in the sent packfile π. Before doing the connectivity check, the client should download from all the given URIs. Currently the supported protocols are"http"and"https".
If the wait-for-done feature is advertised, this arg can go in the client's request:
wait-for-doneβ tells the server it should never send"ready", and instead wait for the client to say"done"before sending the packfile β³
π THE FETCH RESPONSE π
The response of fetch is broken into a bunch of sections separated by delimiter packets (0001), and each section starts with its own section header π. Most sections are only sent when the packfile is sent.
output = acknowledgements flush-pkt |
[acknowledgments delim-pkt] [shallow-info delim-pkt]
[wanted-refs delim-pkt] [packfile-uris delim-pkt]
packfile flush-pkt
acknowledgments = PKT-LINE("acknowledgments" LF)
(nak | *ack)
(ready)
ready = PKT-LINE("ready" LF)
nak = PKT-LINE("NAK" LF)
ack = PKT-LINE("ACK" SP obj-id LF)
shallow-info = PKT-LINE("shallow-info" LF)
*PKT-LINE((shallow | unshallow) LF)
shallow = "shallow" SP obj-id
unshallow = "unshallow" SP obj-id
wanted-refs = PKT-LINE("wanted-refs" LF)
*PKT-LINE(wanted-ref LF)
wanted-ref = obj-id SP refname
packfile-uris = PKT-LINE("packfile-uris" LF) *packfile-uri
packfile-uri = PKT-LINE(40*(HEXDIGIT) SP *%x20-ff LF)
packfile = PKT-LINE("packfile" LF)
*PKT-LINE(%x01-03 *%x00-ff)
π acknowledgments section π
If the client decides it's done negotiating by sending a "done" line (which means the server must send a packfile), then the acknowledgments sections MUST be omitted from the server's response π
ββοΈ
- Always begins with the section header
"acknowledgments"β¨ - The server responds with
"NAK"if none of the object ids sent ashavelines were common. - The server responds with
"ACK obj-id"for all of the object ids sent ashavelines that are common. - A response cannot have both
"ACK"lines and a"NAK"line. Pick a lane bestie π - The server responds with a
"ready"line indicating it's found an acceptable common base and is ready to make and send a packfile (which will be in the packfile section of that same response π₯). - If the server has found a suitable cut point and decided to send a
"ready"line, it can then decide (as an optimization) to omit any"ACK"lines it would've sent in its response. Why? Because the server has already figured out the objects it plans to send to the client, so no further negotiation is needed π§
π¦ shallow-info section π¦
If the client has requested a shallow fetch/clone, a shallow client requests a fetch, or the server is shallow, then the server's response may include a shallow-info section. It'll be included if (because of one of the conditions above) the server needs to tell the client about any shallow boundaries, or about adjustments to the client's already-existing shallow boundaries π
- Always begins with the section header
"shallow-info" - If a positive depth is requested, the server computes the set of commits that are no deeper than the desired depth π
- The server sends a
"shallow obj-id"line for each commit whose parents will not be sent in the following packfile. - The server sends an
"unshallow obj-id"line for each commit that the client indicated is shallow, but which is no longer shallow as a result of the fetch (because its parents are being sent in the following packfile) π£ - The server MUST NOT send any
"unshallow"lines for anything the client did not indicate was shallow as part of its request π ββοΈ
πΈ wanted-refs section πΈ
This section is only included if the client requested a ref with a want-ref line and a packfile section is also included in the response.
- Always begins with the section header
"wanted-refs"π« - The server sends a ref listing (
"<oid> <refname>") for each reference requested usingwant-reflines. - The server MUST NOT send any refs that weren't requested using
want-reflines. No surprise refs, we don't do that here π«
π packfile-uris section π
This section is only included if the client sent packfile-uris and the server has at least one such URI to send.
- Always begins with the section header
"packfile-uris"π - For each URI the server sends, it sends a hash of the pack's contents (as output by
git index-pack) followed by the URI. - The hashes are 40 hex characters long. When Git upgrades to a new hash algorithm, this might need to be updated. (It should match whatever
index-packoutputs after"pack\t"or"keep\t"π§Ύ
π packfile section π
This section is only included if the client has sent want lines in its request and either requested that no more negotiation be done by sending done, or the server has decided it's found a sufficient cut point to produce a packfile π¦
- Always begins with the section header
"packfile"β - The transmission of the packfile begins immediately after the section header π
- The data transfer of the packfile is always multiplexed, using the exact same semantics as the
side-band-64kcapability from protocol version 1. Translation for the girlies: every single packet, during the packfile data stream, is made of a leading 4-byte pkt-line length (iconic pkt-line behavior, no notes), followed by a 1-byte stream code, followed by the actual data.
The stream code can be one of:
1β pack data2β progress messages3β fatal error message just before stream aborts
π«Ά server-option π«Ά
If it's advertised, this means any number of server-specific options can be tucked into a request. How? You send each option as a server-option=<option> capability line, inside the capability-list section of a request. Slay.
The options you provide must not contain aNULorLFcharacter. Like, don't even try it.
π object-format π
The server can advertise the object-format capability with a value X (written as object-format=X) to let the client know the server is able to deal with objects using hash algorithm X. If it's not specified, the server is assumed to only handle SHA-1. If the client would like to use a hash algorithm other than SHA-1, it should specify its own object-format string. Communicate, bestie π
π session-id=<session-id> π
The server may advertise a session ID that can be used to identify this process across multiple requests. And the client may advertise its own session ID right back at the server too. Mutual.
Session IDs should be unique to a given process. They must fit within a packet-line, and must not contain non-printable or whitespace characters. The current implementation uses trace2 session IDs (peep api-trace2[1] for the deets), but this may change and users of the session ID should not rely on that fact. Fickle, we know.
π object-info π
object-info is the command for retrieving information about one or more objects. Its whole main character purpose is to let a client make decisions based on this info without having to fully fetch the objects. Currently only object size and type are supported.
An object-info request takes the following arguments:
sizeβ requests size information to be returned for each listed object id.typeβ requests type information to be returned for each listed object id.oid <oid>β tells the server about an object the client wants to obtain information for. These must be full OIDs.
The response of object-info consists of one pkt-line per requested attribute, echoing the attributes the server will report, followed by one pkt-line per requested object id with its information, each field separated by a single space. Literally so tidy.
output = info flush-pkt
info = *PKT-LINE(attr LF)
*PKT-LINE(obj-info LF)
attr = "size" | "type"
obj-size = 1*DIGIT
obj-type = "blob" | "tree" | "commit" | "tag"
obj-val = obj-size | obj-type
obj-info = obj-id [SP [obj-val *(SP obj-val)]]
The values in obj-info appear in the same order as the corresponding attr lines, with exactly one value per requested attribute. No extras, no skips π
If the server does not recognize the OID, the response will be <oid> SP regardless of the number of attributes requested. Yeah. Just that. A single space and vibes.
π¦ bundle-uri π¦
If the bundle-uri capability is advertised, the server supports the 'bundle-uri' command.
The capability is currently advertised with no value (i.e. it is not "bundle-uri=somevalue"), a value may be added in the future for supporting command-wide extensions. Clients MUST ignore any unknown capability values and proceed with the bundle-uri dialog they support.
The bundle-uri command is intended to be issued before fetch to get URIs to bundle files (see git-bundle(1)) to "seed" and inform the subsequent fetch command.
The client CAN issue bundle-uri before or after any other valid command. To be useful to clients it's expected that it'll be issued after an ls-refs and before fetch, but it CAN be issued at any time in the dialog. Free spirit.
β¨ DISCUSSION of bundle-uri β¨
The intent of the feature is to optimize for server resource consumption in the common case, by changing the common case of fetching a very large PACK during git-clone(1) into a smaller incremental fetch.
It also allows servers to achieve better caching in combination with an uploadpack.packObjectsHook (see git-config(1)).
By having new clones or fetches be a more predictable and common negotiation against the tips of recently produces *.bundle file(s). Servers might even pre-generate the results of such negotiations for the uploadpack.packObjectsHook as new pushes come in.
One way that servers could take advantage of these bundles is that the server would anticipate that fresh clones will download a known bundle, followed by catching up to the current state of the repository using ref tips found in that bundle (or bundles). It's giving strategy π
πΈ PROTOCOL for bundle-uri πΈ
A bundle-uri request takes no arguments, and as noted above does not currently advertise a capability value. Both may be added in the future.
When the client issues a command=bundle-uri request, the response is a list of key-value pairs provided as packet lines with value <key>=<value>. Each <key> should be interpreted as a config key from the bundle.* namespace to construct a list of bundles. These keys are grouped by a bundle.<id>. subsection, where each key corresponding to a given <id> contributes attributes to the bundle defined by that <id>. See git-config(1) for the specific details of these keys and how the Git client will interpret their values.
Clients MUST parse the line according to the above format, lines that do not conform to the format SHOULD be discarded. The user MAY be warned in such a case. (A gentle heads-up, not a jump scare.)
π§ bundle-uri CLIENT AND SERVER EXPECTATIONS π§
URI CONTENTS
The content at the advertised URIs MUST be one of two types.
The advertised URI may contain a bundle file that git bundle verify would accept. I.e. they MUST contain one or more reference tips for use by the client, MUST indicate prerequisites (in any) with standard "-" prefixes, and MUST indicate their "object-format", if applicable.
The advertised URI may alternatively contain a plaintext file that git config list would accept (with the --file option). The key-value pairs in this list are in the bundle.* namespace (see git-config(1)).
bundle-uri CLIENT ERROR RECOVERY
A client MUST above all gracefully degrade on errors β whether that error is because of bad missing/data in the bundle URI(s), because that client is too dumb to e.g. understand and fully parse out bundle headers and their prerequisite relationships, or something else entirely. Graceful degradation is the moment, periodt.
Server operators should feel confident in turning on "bundle-uri" and not worry if e.g. their CDN goes down that clones or fetches will run into hard failures. Even if the server bundle(s) are incomplete, or bad in some way, the client should still end up with a functioning repository, just as if it had chosen not to use this protocol extension.
All subsequent discussion on client and server interaction MUST keep this in mind. Non-negotiable.
bundle-uri SERVER TO CLIENT
The ordering of the returned bundle uris is not significant. Clients MUST parse their headers to discover their contained OIDS and prerequisites. A client MUST consider the content of the bundle(s) themselves and their header as the ultimate source of truth.
A server MAY even return bundle(s) that don't have any direct relationship to the repository being cloned (either through accident, or intentional "clever" configuration), and expect a client to sort out what data they'd like from the bundle(s), if any. Chaos, but make it consensual.
bundle-uri CLIENT TO SERVER
The client SHOULD provide reference tips found in the bundle header(s) as have lines in any subsequent fetch request. A client MAY also ignore the bundle(s) entirely if doing so is deemed worse for some reason, e.g. if the bundles can't be downloaded, it doesn't like the tips it finds, etc.
WHEN ADVERTISED BUNDLE(S) REQUIRE NO FURTHER NEGOTIATION
If, after issuing bundle-uri and ls-refs, and getting the header(s) of the bundle(s), the client finds that the ref tips it wants can be retrieved entirely from advertised bundle(s), the client MAY disconnect from the Git server. The results of such a clone or fetch should be indistinguishable from the state attained without using bundle-uri. Same energy, less traffic π₯
EARLY CLIENT DISCONNECTIONS AND ERROR RECOVERY
A client MAY perform an early disconnect while still downloading the bundle(s) (having streamed and parsed their headers). In such a case the client MUST gracefully recover from any errors related to finishing the download and validation of the bundle(s).
I.e. a client might need to re-connect and issue a fetch command, and possibly fall back to not making use of bundle-uri at all.
This "MAY" behavior is specified as such (and not a "SHOULD") on the assumption that a server advertising bundle uris is more likely than not to be serving up a relatively large repository, and to be pointing to URIs that have a good chance of being in working order. A client MAY e.g. look at the payload size of the bundles as a heuristic to see if an early disconnect is worth it, should falling back on a full "fetch" dialog be necessary.
WHEN ADVERTISED BUNDLE(S) REQUIRE FURTHER NEGOTIATION
A client SHOULD commence a negotiation of a PACK from the server via the "fetch" command using the OID tips found in advertised bundles, even if it's still in the process of downloading those bundle(s).
This allows for aggressive early disconnects from any interactive server dialog. The client blindly trusts that the advertised OID tips are relevant, and issues them as have lines, it then requests any tips it would like (usually from the "ls-refs" advertisement) via want lines. The server will then compute a (hopefully small) PACK with the expected difference between the tips from the bundle(s) and the data requested. Chef's kiss π€
The only connection the client then needs to keep active is to the concurrently downloading static bundle(s) β when those and the incremental PACK are retrieved, they should be inflated and validated. Any errors at this point should be gracefully recovered from, see above. π
bundle-uri PROTOCOL FEATURES π
The client constructs a bundle list from the <key>=<value> pairs provided by the server. These pairs are part of the bundle.* namespace as documented in git-config(1). In this section, we discuss some of these keys and describe the actions the client will do in response to this information. π
In particular, the bundle.version key specifies an integer value. The only accepted value at the moment is 1, but if the client sees an unexpected value here then the client MUST ignore the bundle list. π¨
As long as bundle.version is understood, all other unknown keys MAY be ignored by the client. The server will guarantee compatibility with older clients, though newer clients may be better able to use the extra keys to minimize downloads. π
Any backwards-incompatible addition of pre-URI key-value will be guarded by a new bundle.version value or values in the bundle-uri capability advertisement itself, and/or by new future bundle-uri request arguments. π‘οΈ
Some example key-value pairs that are not currently implemented but could be implemented in the future include: π
- Add a
"hash=<val>"or"size=<bytes>"advertise the expected hash or size of the bundle file. - Advertise that one or more bundle files are the same (to e.g. have clients round-robin or otherwise choose one of N possible files).
- A
"oid=<OID>"shortcut and"prerequisite=<OID>"shortcut. For expressing the common case of a bundle with one tip and no prerequisites, or one tip and one prerequisite.
This would allow for optimizing the common case of servers whoβd like to provide one "big bundle" containing only their "main" branch, and/or incremental updates thereof.
A client receiving such a response MAY assume that they can skip retrieving the header from a bundle at the indicated URI, and thus save themselves and the server(s) the request(s) needed to inspect the headers of that bundle or bundles.
promisor-remote=<pr-info> π¦
The server may advertise some promisor remotes it is using or knows about to a client which may want to use them as its promisor remotes, instead of this repository. In this case <pr-info> should be of the form: π«Ά
pr-info = pr-fields | pr-info ";" pr-fields
pr-fields = pr-field | pr-fields "," pr-field
pr-field = field-name "=" field-value
where all the field-name and field-value in a given pr-fields are field names and values related to a single promisor remote. A given field-name MUST NOT appear more than once in given pr-fields. π«
The server MUST advertise at least the "name" and "url" field names along with the associated field values, which are the name of a valid remote and its URL, in each pr-fields. The "name" and "url" fields MUST appear first in each pr-fields, in that order. π
After these mandatory fields, the server MAY advertise the following optional fields in any order: β¨
partialCloneFilterβ The filter specification for the remote. It corresponds to the"remote.<name>.partialCloneFilter"config setting. Clients can use this to determine if the remoteβs filtering strategy is compatible with their needs (e.g., checking if both use"blob:none"). Additionally they can use this through the--filter=autooption ingit-clone(1). With that option, the filter specification of the clone will be automatically computed by combining the filter specifications of the promisor remotes the client accepts.tokenβ An authentication token that clients can use when connecting to the remote. It corresponds to the"remote.<name>.token"config setting.
No other fields are defined by the protocol at this time. Field names are case-sensitive and MUST be transmitted exactly as specified above. Clients MUST ignore fields they donβt recognize to allow for future protocol extensions. π§
The client can use information transmitted through these fields to decide if it accepts the advertised promisor remote. Also, the client can be configured to store the values of these fields or use them to automatically configure the repository (see "promisor.storeFields" in git-config(1) and --filter=auto in git-clone(1)). π
Field values MUST be urlencoded. π
If the client decides to use one or more promisor remotes the server advertised, it can reply with "promisor-remote=<pr-names>" where <pr-names> should be of the form:
pr-names = pr-name | pr-names ";" pr-name
where pr-name is the urlencoded name of a promisor remote the server advertised and the client accepts. π
The promisor remotes that the client accepted will be tried before the other configured promisor remotes when the client attempts to fetch missing objects. π₯
Note that, everywhere in this document, the ; and , characters MUST be encoded if they appear in pr-name or field-value. βΌοΈ
If the server doesnβt know any promisor remote that could be good for a client to use, or prefers a client not to use any promisor remote it uses or knows about, it shouldnβt advertise the "promisor-remote" capability at all. π
βοΈ
In this case, or if the client doesnβt want to use any promisor remote the server advertised, the client shouldnβt advertise the "promisor-remote" capability at all in its reply. π¬
On the server side, the "promisor.advertise" and "promisor.sendFields" configuration options can be used to control what it advertises. On the client side, the "promisor.acceptFromServer" and "promisor.acceptFromServerUrl" configuration options can be used to control what it accepts, and the "promisor.storeFields" option, to control what it stores. See the documentation of these configuration options in git-config(1) for more information. π
Note that in the future it would be nice if the "promisor-remote" protocol capability could be used by the server, when responding to git fetch or git clone, to advertise better-connected remotes that the client can use as promisor remotes, instead of this repository, so that the client can lazily fetch objects from these other better-connected remotes. This would require the server to omit in its response the objects available on the better-connected remotes that the client has accepted. This hasnβt been implemented yet though. So for now this "promisor-remote" capability is useful only when the server advertises some promisor remotes it already uses to borrow objects from. π
GIT π
Part of the git(1) suite. π
NOTES π
api-trace2βfile:///usr/share/doc/git-doc/technical/api-trace2.html
okay bestie, thatβs the whole page β shoutout to Git 2.56.0, dated 2026-09-27, for this GITPROTOCOL-V2(5) moment. slayed, no cap. π
β¨π«Ά
π¦ where this page comes from
- arch rolling: git 2.56.0-1 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms