DEV Community

shun
shun

Posted on

1

Thoughts on Write yourself a Git!

Article in question: https://wyag.thb.lt/

Going through this article provided me with a deeper understanding on how Git works. It's a tool which we use daily but don't really understand how it works.

I ask myself was there any point of this? I'm not sure really, I won't be asked to build my own Git. But, it was interesting to understand or have an inkling on how Git works at its core. Moreover, there were moments where I find myself saying: 'Oh this is how it works' and feel a tinge of excitement which I've not felt in a while.

It was cool to consume, verify and implement the content of the article. For example, it mentions that Git objects exists in .git/objects, I proceeded to verify it and confirm that it actually exists. Additionally, now I understand how the folders and file are structured under it. The first two character of the SHA-1 hash is the folder name and the remaining characters is the binary file name.

Though I mentally checked out on part 9, I pressed on and went through the article in one pass. There are still a lot of concepts that are still unknown / abstract / confusing to me such as a tree object. In the article it mentions that a tree object is special as it's a binary object but aren't tags and commit binary objects too?

But I tend to not dwell too much on it, I just note it down, move forward and complete the tutorial to get a bigger picture allowing me to connect the dots backwards.

Other than noting down parts I'm not sure on, I wrote down a question and answer deck along the way so that I can insert into Anki for revision. For example:

  • What is a git object? Git objects are binary file that represent files within a repository. These objects usually lives in '.git/object' and it's identified by a SHA-1 hash which is derived from the contents of the file. Thus git doesn't actually store files
  • What happens when a file in git is modified? Instead of updating a file, a new file is created in a different location

Lastly, I'm going through this content a second ~ nth time to reinforce the concept taught, modifying the code to reflect my understanding and reduce cognitive load. For example, I'm intending to split up the different git commands to separate files for easy reading and introduce typings to the parameters to know what it should expect. But this is only possible if I've went through it the first time round. Essentially, I'm replicating first before iterating the content with my own twist


For those interested in the code I've written up it's here: https://github.com/tanshunyuan/build-my-own-x/tree/main/wyagit

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

While many AI coding tools operate as simple command-response systems, Qodo Gen 1.0 represents the next generation: autonomous, multi-step problem-solving agents that work alongside you.

Read full post →

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post