New upstream version 0.19.10
[jelmer/dulwich.git] / docs / protocol.txt
1 .. _protocol:
2
3 ===================
4 Git Server Protocol
5 ===================
6
7 Transport
8 =========
9
10 The Git protocol operates over pipes or TCP/IP. When a client connects over
11 TCP/IP, it sends a header that tells the server which program to run and what
12 parameters to use. When invoked over SSH, git will run a program with the
13 parameters as command line arguments.
14
15 Protocols
16 =========
17
18 Basics
19 ------
20
21 Git communicates with a server by piping data between a local program and a
22 remote program.
23
24 A common way of sending a unit of information is a pkt_line. This is a 4 byte
25 size as human encoded hex (i.e. totally underusing the 4 bytes...) that tells
26 you the size of the payload, followed by the payload. The size includes the 4
27 bytes used by the size itself.
28
29     0009ABCD\n
30
31 Git can also multiplex data using the sideband. As well as 4 bytes size, there
32 would be a 1 byte channel number. This is in binary, so ``1`` will be ``\x01``.
33
34 Typically Git will piggyback a list of capabilities on the first pkt_line it
35 sends. It will also look for capabilities in the first pkt_like it receives.
36 Git will degrade as much as possible when encountering a server or client with
37 differing capabilities.
38
39 git-upload-pack
40 ---------------
41
42 git-upload pack is used by git-ls-remote, git-clone, git-fetch and git-pull.
43 And i'm sure others. Typically a client will connect a local git-fetch-pack to
44 a remote git-upload-pack.
45
46 Capabilities for this protocol include multi_ack, thin-pack, ofs-delta,
47 sideband and sideband-64k A thin pack can reference objects not in the current
48 pack.
49
50 The server tells the client what refs it has. The client states which of those
51 SHA1's it would like. It then starts to report which SHA1's it has. The server
52 ACKs these allowing the client to work out when to stop sending SHA1's. This
53 saves a lot of transfer because the client can make decisions like "well if it
54 has this SHA, then it has all its parents so I don't need to care about those".
55 When the client stops sending shas, the server can work out an optimal pack and
56 then send it to the client.
57
58 git-receive-pack
59 ----------------
60
61 git-receive-pack is used by git push. Typically a client connects a local
62 git-send-pack to a remote git-receive-pack.
63
64 Capabilities include report-status and delete-ref.
65