I always thought of git index just a staging area, i e. when nothing is staged after git commit, index is empty, where as head is the sum of all previous commited indexes reached from the head.
Apparently this mindset is wrong, regarding how git reset --soft <ref>
preserves the index according to doc. When i soft reset from clean working directory to earlier commit, the changes introduced on later commits are staged automatically, i.e added to index. Or more precisely, they aren't added on the index of the current commit, but the whole index is transferred.
Does this mean the index of clean commit directory actually contains the changes of previous commit, as well as the head does? Does commiting actually commits the difference between head and index? Does cleanliness and diffs of the working directory mean the difference to the index, rather than to the head? What is exactly the index as a data structure, how does git add
or git commit
change it? How it evolves commit after commit, how it relates to the concept of snapshot and deltas?