Skip to content

Instantly share code, notes, and snippets.

@branneman
Last active March 23, 2023 13:15
Show Gist options
  • Save branneman/6501d0d2310256396091400dc30b3e31 to your computer and use it in GitHub Desktop.
Save branneman/6501d0d2310256396091400dc30b3e31 to your computer and use it in GitHub Desktop.
How Git works - super simplified! — https://www.youtube.com/watch?v=T9Nag5IXVQ0
// blob = file contents, identified by hash
const blobs = {
'73d8a': 'import x from "y"; console.log("some file contents")',
'9c6bd': 'D8 A1 31 0F ...',
'547d4': '# Readme\nThis is documentation',
'a0302': '# Readme\nThis is some updated documentation',
}
// tree = references to blobs and trees, identified by hash
const trees = {
'811cb': [
'blob: 9c6bd logo.png',
'blob: 73d8a main.js',
],
'877af': [
'tree: 811cb source',
'blob: 547d4 readme.md',
],
'7d676': [
'tree: 811cb source',
'blob: a0302 readme.md',
],
}
// commit = ref to tree + metadata, identified by hash
const commits = {
'841b9': {
tree: '877af',
parent: null,
message: 'feat: Initial commit, add file structure',
author: 'bran',
datetime: '1970-01-01 13:37:00',
},
'199df': {
tree: '7d676',
parent: '841b9',
message: 'docs: Update readme',
author: 'colleague',
datetime: '1971-02-02 13:37:00',
},
}
// branch/tag/ref = named pointers to commit
const refs = {
'HEAD': '199df',
'main': '199df',
'feature/xyz': '841b9',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment