git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Git network protocol

From
JSJosef "Jeff" Sipek <jeffpc@josefsipek.net>
Date
Aug 14, 2006, 06:21 UTC
Message-ID
<20060814062117.GC10476@josefsipek.net>
Hello,

I'm trying to implement the git protocol, and I am having a bit of an issue with the lack of information available about it (please correct me if I missed some source of information.)

I understand the basic format of the protocol, however I'm not sure what "command" can follow what. I also noticed some odd inconsistencies (or maybe I just don't see the pattern yet.) For example, a git-clone generates this traffic:

C: git-upload-pack ....
S: SHA1 HEAD....
S: SHA1 refs/heads/master
S: flush
C: want SHA1...
C: want SHA1... (it wants the same SHA1 twice!)
C: flush
C: done
S: NAK
S: the pack...
Then, when it is time to git-fetch a new commit, I get:
C: git-upload-pack ....
S: SHA1 HEAD....
S: SHA1 refs/heads/master
S: flush
C: want SHA1...
C: flush
C: have SHA1
C: done
S: ACK SHA1 continue
S: ACK SHA1 (same hash)
S: the pack...
Then, if I try to git-fetch but there is nothing new, I get:
C: git-upload-pack ....
S: SHA1 HEAD....
S: SHA1 refs/heads/master
S: flush
C: flush
<client closes connection>

So, I can _assume_ that "done" tells the server that it is time to make a pack. Why does the server use NAK during the clone operation, but ACK during fetch? Why does the server ACK the same SHA1 twice? And why does the client "want" the same SHA1 twice? It just seems odd.

I think it would be great if there was some kind of description somewhere that detailed the protocol. Also, the daemon source isn't the prettiest thing in the world.

Thanks, Josef "Jeff" Sipek.

-- 
Reality is merely an illusion, albeit a very persistent one.
		- Albert Einstein
Next: Junio C Hamano
Message 1 of 5 in “Git network protocol”
  1. Josef "Jeff" SipekAug 14, 2006
  2. Junio C HamanoAug 14, 2006
  3. Josef "Jeff" SipekAug 14, 2006
  4. Junio C HamanoAug 15, 2006
  5. Josef "Jeff" SipekAug 15, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.