Git Internals
Working Tree, Index, and Object Store
Separating the working tree, index, and object database is the clearest way to understand add, commit, restore, and reset.
Many Git problems become easier once these three layers are separated:
- working tree: files you are editing now
- index: the next snapshot being prepared
- object store: durable Git objects already written
Why this matters
The real difference between many commands is simply which layer they touch:
git addupdates the indexgit commitwrites index state into durable objectsgit restorecan restore the working tree or the indexgit resetcan move refs and may also realign the index and working tree
If you treat the index as “the candidate snapshot for the next commit,” Git behavior becomes much more predictable.