Git: From init to a KV Database
#FF0000 Leather Pants.
Developer.
@yburyug - Twitter
ybur-yug - Github
Git
An Introduction
mkdir git_stuff
cd git_stuff
git init
tree .git
.git
├── branches
├── config
├── description
├── HEAD
├── hooks
│ ├── applypatch-msg.sample
│ ├── commit-msg.sample
│ ├── post-update.sample
│ ├── pre-applypatch.sample
│ ├── pre-commit.sample
│ ├── prepare-commit-msg.sample
│ ├── pre-push.sample
│ ├── pre-rebase.sample
│ └── update.sample
├── info
│ └── exclude
├── objects
│ ├── info
│ └── pack
└── refs
├── heads
└── tags
Directed Acyclic Graph vs Tree
Objects
Hashin' and Cattin'
echo "test" > test.txt
git status
git add test.txt
git commit -m 'YOLO'
tree .git
.git
├── branches
├── COMMIT_EDITMSG
├── config
├── description
├── HEAD
├── hooks
│ ├── ...
│ └── update.sample
├── index
├── info
│ └── exclude
├── logs
│ ├── HEAD
│ └── refs
│ └── heads
│ └── master
├── objects
│ ├── 2b
│ │ └── 297e643c551e76cfa1f93810c50811382f9117
│ ├── 8c
│ │ └── dd94550187df2f165cc67305fe9fcc27b98e62
│ ├── 9d
│ │ └── aeafb9864cf43055ae93beb0afd6c7d144bfa4
│ ├── info
│ └── pack
└── refs
├── heads
│ └── master
└── tags
15 directories, 21 files
│ ├── 9d
│ │ └── aeafb9864cf43055ae93beb0afd6c7d144bfa4
Naming Format:
2 chars as dirname + hash inside
echo "Yolt" | git hash-object -w --stdin
#=> 8ac7f99313f02f7bfaf45426ffe514075232bad4
# -w = actually write data
# --stdin to take the i/o from stdin
git cat-file -p 8ac7f99313f02f7bfaf45426ffe514075232bad4
#=> Yolt
hash-object == set
cat-file == get
A Bit Deeper
Every Version. Ever
.git/objects/two_chars/rest_of_hash
Wrapping it as a DB
Ruby time!
Q & A
.git
- Trees
- Objects
- Refs
Git: From init to a KV DB
By Bobby Grayson
Git: From init to a KV DB
- 2,123