Let's tackle it!
The book is predicated on a neat idea: let's write our own version of
git and base our implementation on observing
git, logging system calls and (where we must) reading the source code. We call it
Jit and it's written in Ruby.
gem install jit
2. Getting to know
What's the bare minimum needed to
.git/HEAD contains a reference to the current commit.
# cat .git/HEAD ref: refs/heads/main
- reflog - reference log
- symref - symbolic reference
.git/info/exclude is presented as a possible alternative to
.gitignore is part of the source tree, the contents of
.git/info/exclude are local to that copy of the repository.
On to more good stuff
When an object is first added to the database, it's stored in its own file as a
loose object. On certain events, files are assembled into a
index files describe where to find a particular item in a
pack. This can be triggered with
git init tree .
Inspect the contents.
A simple commit¶
root commit is a commit with no parents.
ref can point to a commit (like
HEAD) or a branch...for example. That's not an exhaustive list. The
reflog command uses
.git/logs. Ah, the conten of
.git/refs/heads/main will tell us which commit is at the tip of the