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

Re: About GIT Internals

From
EEErik Cervin Edin <erik@cervined.in>
Date
May 25, 2022, 21:14 UTC
Message-ID
<CA+JQ7M_OmfJVJpnYc1h=L226nZqo0A=5USCEJAgrK2EKPRsW4w@mail.gmail.com>
In-Reply-To
<CACMKQb0Mz4zBoSX2CdXkeF51z_mh3had7359J=LmXGzJM1WYLg@mail.gmail.com>
On Wed, May 25, 2022 at 10:14 PM Aman <amanmatreja@gmail.com> wrote:
>
> And if I am being completely honest, I didn't understand most of it.

You are not alone, there are many that struggle with understanding how git works internally.

> (I am a high school student, and really want to learn more about how
> all the great software and hardware around us work - which so many of
> us take for granted)

Perhaps not a good resource, depending on your familiarity with computer science but https://eagain.net/articles/git-for-computer-scientists/ is an article that is often recommended.

I think for me, the hardest part of understanding Git was the difficulty conceptualizing it. But at its core Git is very simple.

You can think of it as a folder of files that you can "save" (commit) whenever you want. Each time you "save" (commit), all files and folders are "copied" to another folder (the local repository). That means that if you ever want to look at a previous version of a file, it's there. For simplicity's sake you can think of this as being unchangeable. Once a file is saved it's saved forever.

Just having a messy pile of every single version of a file is not useful, so the rest of git consists of making this manageable. For example by remembering who saved it, when and why (by making them write a message when they save).

The main thing however is that Git orders saves. This order is not necessarily one version after another, sorted by when they were saved. Instead, order is manually controlled by saving files in different places (branches). In its simplest form, a branch is several saves, one after another.

Because of how Git orders saves, I can work on files, save them and give them to you. You can keep working on those files and make your own saves. But I don't have to wait for you to send your work back to me. I can keep working on the same files and making my own saves.

When you're done you can put your saves in a "shared folder" (a remote repository). Later, when I'm done, I can get your saves and Git can help me figure out which parts of the files that you changed that I didn't and copy both of our work into new files (merging).

This is a bit of an oversimplification and Git allows users to do more advanced things but the gist is basically this.

Previous: Emily ShafferNext: git-vger@eldondev.com
Message 3 of 17 in “About GIT Internals”
  1. AmanMay 25, 2022
  2. Emily ShafferMay 25, 2022
  3. Erik Cervin EdinMay 25, 2022
  4. git-vger@eldondev.comMay 25, 2022
  5. Philip OakleyMay 26, 2022
  6. Konstantin KhomoutovMay 26, 2022
  7. Philip OakleyMay 27, 2022
  8. Kerry, RichardMay 30, 2022
  9. Konstantin KhomoutovMay 30, 2022
  10. Ævar Arnfjörð BjarmasonMay 30, 2022
  11. AmanJun 3, 2022
  12. Emily ShafferJun 3, 2022
  13. Junio C HamanoJun 3, 2022
  14. Konstantin KhomoutovJun 3, 2022
  15. AmanJun 4, 2022
  16. Konstantin KhomoutovJun 6, 2022
  17. Philip OakleyMay 27, 2022

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.