Staging area (Git index)
Definition
The Git index collects the intended content of the next commit before its creation.
The staging area, also called the index, holds in Git the file state selected for the next commit. Changes are added there with git add. Working directory, index, and last commit can differ; later file edits are not automatically re-selected for the commit.
Simply explained
You place selected changes into a holding tray. Only the next commit packages exactly this prepared state as a saved version.
Why it matters in practice
Teams can deliberately bundle related changes and review before a commit which content should actually enter the version history.
Example from business
Possible example: A developer selects only the changes of a bug fix and reviews the prepared diff before creating the corresponding commit.
Limits and pitfalls
- Files edited afterward may differ from the already staged state. Adding all files unchecked can include accidental or unrelated changes.
Origin & history
The index is part of the Git working model and separates ongoing editing from the deliberate assembly of a commit.
Use in mid-sized companies
- A company can require a review of staged changes before each commit in the development process and include only thematically related parts when mixing work.
Frequently asked questions
Does git add already save a commit?
No. It updates the index; only git commit creates the new saved development state from it.
Sources
- git-add. · Git (o. J.): git-add.
Editorially reviewed on: