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

Git clone question

From
SPSankar P <sankar.curiosity@gmail.com>
Date
Apr 7, 2020, 18:22 UTC
Message-ID
<CAMSEaH5eZdNooNHQJAto_0dCZSFtiji8ZYvft+oZQXfzDHSyEg@mail.gmail.com>
In-Reply-To
<CAMSEaH6+fQuDjhY-5THoYpEjjrHU4Sofnmr-nASHaTZbHvQw1w@mail.gmail.com>
Hi
I am trying to understand about git clone.

From the few git videos that I have watched and using git, I understand that git stores the difference between each version, as an object, with the sha of the diff as the way to address the object.

However, what is not clear to me is, how does `git clone` then work ? If a repository has a thousand commits, do we download all the thousand objects to the client system and then apply them one on top of the other ? I am sure that must not be the case because the `git clone` operation completes so fast, and I doubt if my disks are that fast.

However, when I do a `git clone` I could see the history until the first commit.

I can also partially ignore the history and clone only the last N commits history too. So my question is, how does `git clone` work under the hood and how is it so fast ? Does the git server save the expanded git tree (with all the git patches applied) and we just transfer them when we do the `git clone` ?

Are there any good talks / papers / books on the internals of the working of git ?

Thanks.
-- 
Sankar P
http://psankar.blogspot.com
Next: Bryan Turner
Message 1 of 3 in “Git clone question”
  1. Sankar PApr 7, 2020
  2. Bryan TurnerApr 7, 2020
  3. Sankar PApr 8, 2020

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.