It never had to be like this: the git "index" - the sporks space

submited by
Style Pass
2021-08-18 14:00:12

Hot on the heels of another Git-related article that was making the rounds recently, I was reminded of Git’s own structure and how it influences user experience. Specifically what we assume is part of how Git works, is actually a part of the porcelain (in Git speak, the user interface and commands that back it). As someone developing a Git client, it’s interesting to think Git’s user experience could be significantly different with a different interface, particularly because people have a particular mental model of Git influenced by the default interface. Said influence is enough that libgit2’s API emulates the porcelain’s semantics, in-process.

The index, stage, cache – whatever you want to call it – is the middleman that records the state of files. Confusingly, all the names are arguably valid:

It should be noted that the index is actually not what gets written out as part of a commit. While the differences recorded in the index are used to make the commit, the directory structure – not the index – is stored in tree objects. The format of the tree entries is much simpler than the index’s. The index is more a convenience for tracking changes out of the checked-out working tree.

Leave a Comment