Git–Why Should I Care about the Index?

By Charles Bailey

One of the unique features of Git is its “index” but it is often poorly understood and frequently cited as confusing, especially for newcomers to Git.

What is the index and why does Git have it?

The index is a staging area for your next commit. It is also a “stat” cache which ensures that Git has the performance characteristics that it needs. The index is also the merge resolution area. The fact that the index supports these diverse purposes contributes to its conceptual complexity.

To dispel some of the confusion that surrounds the index we look at the internals, what is stored in the index and how it is stored.

We look at what operations read and update the index in normal usage. We also examine what commands we can use to deliberately affect the index and why we might want to perform them.