Skip to content

Instantly share code, notes, and snippets.

@brewkode
Created July 20, 2020 21:01
Show Gist options
  • Save brewkode/6a5e8e2390abc57e377fa335effca288 to your computer and use it in GitHub Desktop.
Save brewkode/6a5e8e2390abc57e377fa335effca288 to your computer and use it in GitHub Desktop.
Rough notes on git data model
# Git's data model
## Snapshot
collection of files & folders within a top-level dir as a series of snapshots.
- file is a "blob", bunch of bytes
- directory is a "tree" which maps names to blobs or trees
- snapshot is a top-level tree that is being tracked
## History
- DAG
- each snapshot refers to a "set of parents";
- snapshots is called "commit" in git
- "commits" are "immutable" in git
- edits to commit history will create new commits & references will be updated accordingly
## Pseudocode
```
blob = array<byte>
tree = map<string, tree | blob>
commit = struct {
parent: array<commit>
author: string
message: string
snapshot: tree
}
type object = blob | tree | commit
objects = map<string, object>
```
## poking at git objects:
```
git cat-file -p SHA
git cat-file -p REF
```
## Git References
References are pointers to commits
references = map<string, string>
## Git Repository
It's just a collection of objects & references
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment