3.1 The Git Triumvirate: the repo, the index, and the work dir

Figure 3.1 and Figure 3.2 show the relationships between the three main ‘parts’ of Git.

The index contains a list relating hash and mode to file paths.

PIC

Figure 3.1:The Git Triumvirate: in-flow

PIC

Figure 3.2:The Git Triumvirate: out-flow

Author Note

Use the diff command to illustrate how the index works.

the index ‘marks’ all files considered ‘tracked’ in the workspace.

files in the workspace with no entry in the index are ‘untracked’

files in the index with hashes different to those in the workspace are ‘modified’

the index refers to ‘staged’ files. These have hashes (and blobs in the objects store) that are NOT a part of the last commit tree (referened by HEAD).

It is therefore possible to have a single file both ‘modified’ (its workspace content differs from that referred to by the index) AND ‘staged’ (the ndex refers to an blob that is not the one referenced in the HEAD commit)