1
- Git Wire Protocol, Version 2
2
-==============================
1
+Git Wire Protocol, Version 2
2
+============================
3
4
This document presents a specification for a version 2 of Git's wire
5
protocol. Protocol v2 will improve upon v1 in the following ways:
22
has completed, a client can reuse the connection and request that other
23
commands be executed.
24
25
- Packet-Line Framing
26
----------------------
25
+Packet-Line Framing
26
+-------------------
27
28
All communication is done using packet-line framing, just as in v1. See
29
`Documentation/technical/pack-protocol.txt` and
34
* '0000' Flush Packet (flush-pkt) - indicates the end of a message
35
* '0001' Delimiter Packet (delim-pkt) - separates sections of a message
36
37
- Initial Client Request
38
-------------------------
37
+Initial Client Request
38
+----------------------
39
40
In general a client can request to speak protocol v2 by sending
41
`version=2` through the respective side-channel for the transport being
43
found in `pack-protocol.txt` and `http-protocol.txt`. In all cases the
44
response from the server is the capability advertisement.
45
46
- Git Transport
47
-~~~~~~~~~~~~~~~
46
+Git Transport
47
+~~~~~~~~~~~~~
48
49
When using the git:// transport, you can request to use protocol v2 by
50
sending "version=2" as an extra parameter:
51
52
003egit-upload-pack /project.git\0host=myserver.com\0\0version=2\0
53
54
- SSH and File Transport
55
-~~~~~~~~~~~~~~~~~~~~~~~~
54
+SSH and File Transport
55
+~~~~~~~~~~~~~~~~~~~~~~
56
57
When using either the ssh:// or file:// transport, the GIT_PROTOCOL
58
environment variable must be set explicitly to include "version=2".
59
60
- HTTP Transport
61
-~~~~~~~~~~~~~~~~
60
+HTTP Transport
61
+~~~~~~~~~~~~~~
62
63
When using the http:// or https:// transport a client makes a "smart"
64
info/refs request as described in `http-protocol.txt` and requests that
79
Subsequent requests are then made directly to the service
80
`$GIT_URL/git-upload-pack`. (This works the same for git-receive-pack).
81
82
- Capability Advertisement
83
---------------------------
82
+Capability Advertisement
83
+------------------------
84
85
A server which decides to communicate (based on a request from a client)
86
using protocol version 2, notifies the client by sending a version string
101
key = 1*(ALPHA | DIGIT | "-_")
102
value = 1*(ALPHA | DIGIT | " -_.,?\/{}[]()<>!@#$%^&*+=:;")
103
104
- Command Request
105
------------------
104
+Command Request
105
+---------------
106
107
After receiving the capability advertisement, a client can then issue a
108
request to select the command it wants with any particular capabilities
137
optionally send an empty request consisting of just a flush-pkt to
138
indicate that no more requests will be made.
139
140
- Capabilities
141
---------------
140
+Capabilities
141
+------------
142
143
There are two different types of capabilities: normal capabilities,
144
which can be used to to convey information or alter the behavior of a
153
permits simple round-robin load-balancing on the server side, without
154
needing to worry about state management.
155
156
- agent
157
-~~~~~~~
156
+agent
157
+~~~~~
158
159
The server can advertise the `agent` capability with a value `X` (in the
160
form `agent=X`) to notify the client that the server is running version
168
and debugging purposes, and MUST NOT be used to programmatically assume
169
the presence or absence of particular features.
170
171
- ls-refs
172
-~~~~~~~~~
171
+ls-refs
172
+~~~~~~~
173
174
`ls-refs` is the command used to request a reference advertisement in v2.
175
Unlike the current reference advertisement, ls-refs takes in arguments
199
symref = "symref-target:" symref-target
200
peeled = "peeled:" obj-id
201
202
- fetch
203
-~~~~~~~
202
+fetch
203
+~~~~~
204
205
`fetch` is the command used to fetch a packfile in v2. It can be looked
206
at as a modified version of the v1 fetch where the ref-advertisement is
444
2 - progress messages
445
3 - fatal error message just before stream aborts
446
447
- server-option
448
-~~~~~~~~~~~~~~~
447
+server-option
448
+~~~~~~~~~~~~~
449
450
If advertised, indicates that any number of server specific options can be
451
included in a request. This is done by sending each option as a