Write Yourself a Git (by Thibault Polge) - Part 3
In the last post, I was trying to explore a sample git repo of my own, but was running into all sorts of trouble with compression, packing and whatnot.
These concepts and their implementations are about “efficiency”. They are not core to understanding the “git model”.
I felt, I need a repo - where all these fancy real-world optimizations of git are disabled so I can inspect a git repo at peace.
Today I present: git-learning-mode.
You can clone this repo:
git clone git@github.com:shrsv/git-learning-mode.git
Then you can run the “learning mode” script:
chmod a+x git-learning-mode.sh
./git-learning-mode.sh
And it automatically configures the local repo to disable all optimizations that may hinder initial understanding of the core github model:
There is no longer any:
Automatic packing
Delta compression
Storage mutation
Pruning of unreachable objects
Auxiliary indices
And so on. It just keeps the repo simple, bare minimum.
Now let’s do “make list-objects” to get a list of objects in the repo:
$ make list-objects
find .git/objects -type f
.git/objects/e6/d72ee179788d3e177170e705cafc9fe852bb6c
.git/objects/54/e8580aa1957560318f5363f4b2d2c28a2fc94e
.git/objects/9c/00decc006ba1dabf9bd54b5bcec6ff1e335435
.git/objects/ee/a9a3bb1c8e7e4fb23abf23d9196471795b4500
.git/objects/b6/2fd616213b0d00a210db473e15f710cdfc96f0
.git/objects/pack/pack-4cb93da30fb7e10ac5d5b1365b73368b48b23d27.rev
.git/objects/pack/pack-4cb93da30fb7e10ac5d5b1365b73368b48b23d27.idx
.git/objects/pack/pack-4cb93da30fb7e10ac5d5b1365b73368b48b23d27.pack
.git/objects/a3/8398e1b53a3b1c0204816b872c1db21bd2befa
.git/objects/80/7abe4fdb5db669b1951586d5b942e9a90ff047
We can see the pattern described in the last section. First two chars of the file has become folder name. Rest of the hash becomes the filename.
Here’s a utility to find object type, again using a simple make file trick - “make object-type”:
And we get:




