2 ms·
I don't think I've fully grokked git, but 1. There is a similarity with Lisp. A commit is an object with a pointer to the next one (or multiple parents). These
by kazinator 4y ago
I don't think I've fully grokked git, but
1. There is a similarity with Lisp. A commit is an object with a pointer to the next one (or multiple parents). These objects are garbage collected. Heads point to commits: they are like root pointers. These pointers are mutating. When a new commit is made, it's a lot like a new cons cell pushed onto a list in Lisp: (push new-commit HEAD). (Stupidly, git history isn't terminated by the equivalent of NIL; yet some git operations require a parent. There are ugly workarounds.)
2. Key insight: commits store snapshots, not deltas. Diffs are calculated.
I've slightly delved into the internals.
1. I developed a procedure for reordering commits on a branch with zero conflicts, using tree objects directly, without any rebase workflow. So that is to say, we peel back the brandch, and then create commits using the tree objects of the original commits, in whatever order we want. Because git is based on snapshots, there are no conflicts: it's not a rebase operation on cherry picks.
2. I went through an exercise once of manually creating a stash entry, by creating the right objects and editing some text files in .git