Selecting changes

The ability to select changes and store them temporarily before commit has many benefits and requires the existence of a staging area.

separation of concern

We keep the working directory and the staging area (index) separate to aknowledge their different role.

the role of the working directory

The working directory is a playground where changes are not saved, good for exploration and iteration. Its content has no influence on what is saved when we perform a commit.

This allows to keep a file that we don't plan to commit yet or that we never intend to commit. Such file is called untracked if it has never been part of a commit, and modified if it was part of a commit but has changed since. (If the file is added to the staging area, we may not use those adjectives anymore)

the role of the staging area (index)

The staging area is directly tied to what is saved when we perform a commit. Adding to the staging requires the explicit git add command.

This favors explicitness and intent, and flexibility, because we don't have to save everything at once. We may selectively pick files or lines. Such granularity allows to group related changes and separate unrelated ones.

the index as a temporary storage area for temporary checkpoints

To further the distinction with the working directory, the index has its own storage: it may contain files that not present in the working directory, or a different version.

Such storage may save temporary work as a sort of checkpoint. This allows to iterate on further changes, with the ability to revert to the checkpoint if needed.

earlymorning logo

© 2025 - All rights reserved

Selecting changes

The ability to select changes and store them temporarily before commit has many benefits and requires the existence of a staging area.

separation of concern

We keep the working directory and the staging area (index) separate to aknowledge their different role.

the role of the working directory

The working directory is a playground where changes are not saved, good for exploration and iteration. Its content has no influence on what is saved when we perform a commit.

This allows to keep a file that we don't plan to commit yet or that we never intend to commit. Such file is called untracked if it has never been part of a commit, and modified if it was part of a commit but has changed since. (If the file is added to the staging area, we may not use those adjectives anymore)

the role of the staging area (index)

The staging area is directly tied to what is saved when we perform a commit. Adding to the staging requires the explicit git add command.

This favors explicitness and intent, and flexibility, because we don't have to save everything at once. We may selectively pick files or lines. Such granularity allows to group related changes and separate unrelated ones.

the index as a temporary storage area for temporary checkpoints

To further the distinction with the working directory, the index has its own storage: it may contain files that not present in the working directory, or a different version.

Such storage may save temporary work as a sort of checkpoint. This allows to iterate on further changes, with the ability to revert to the checkpoint if needed.