Git loves to mix the "concept" with the "implementation", with overlaps all the way down (e.g. refs and branch names are just a "string of characters", but for convenience it started as a file path with the `/` slash delimiters ..
So. The DirCache/Cache/Index/Staging area are all very similar with slightly different levels of misdirection. Importantly (as implementation), the Object Store is where all the "content" is located which includes what is formally in the repository, what is waiting to be added to the repository (staging area) and also all the temporary content. The Index (implemented as a structured file) is the 'database' of what is in the current top level commit, and what is waiting to be committed (staged), along with temporary files while merging etc (e.g. for conflicts). However, in colloquial discussion, the context of the discussion is used to indicate which part is being talked about, so when 'staging' (adding) a file ready for the next commit, it is "added to the index", as if that's all that's in the index. When looking at the current files, we can 'look at the index' to see how they compare to the last commit, and for sparse checkout, the index keeps a note of which commit objects are really in the file system at the moment, and which are still in the object store (because they haven't and won't be changed, so no need to 'check them out'). That's my viewpoint any way. Hope it helps. On Monday, February 14, 2022 at 2:38:31 AM UTC [email protected] wrote: > I have been reading a lot about the git index. Many blogs seem to explain > it as some area where the diffs of tracked file gets "staged" for commit. > In short, I would the get the general idea that the index is empty 99% of > the time and it only gets populated only when I make some changes to a > tracked file or make a new un-tracked file. > > However, when reading about sparse-index, I got confused again because it > seems to explain the index as a place where all of the contents of the > repository gets stored. > > So which one is the correct one? > > Also, index and staging area are the same thing, right? > -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/git-users/fbc9ccec-00b5-4d04-8800-3a4b30060cedn%40googlegroups.com.
