iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Git’s staging area—also called the index—holds the proposed content of your next commit. git add copies selected content from your working files into that index; a later edit does not update it automatically. A normal git commit records the staged state.
How Git’s three states fit together
To understand staging, distinguish the current commit, the index, and the working tree. They represent separate states, even when their contents happen to match.
| State | What it represents |
|---|---|
HEAD |
The current commit: the snapshot your branch currently points to. |
| Index | The proposed snapshot for the next ordinary commit. |
| Working tree | The files in your checkout that you can edit. |
The index is not a live view of the working tree. It records staged content separately, which is why the file on disk can change without changing what is queued for a commit. The Git project describes the index as a list of paths and content, with entries recording file type, object ID, stage number, and path; it is not itself a directory tree. Git’s data model documentation explains how that list is used to build a tree.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteWhat does git add actually do?
When you run git add path, Git reads the selected file content from the working tree and updates the index. It stages a content snapshot; it does not merely mark a filename, and it does not create a commit. If you edit the file again afterward, the index retains the content captured by that earlier git add. To stage the newer content, add the file again. See the git add documentation.
#1 Best Overall
For example, suppose file.txt matches HEAD. You edit it and run git add file.txt. That version is now in the index. If you then edit file.txt again, the new edit exists only in the working tree until you stage it.
How do you tell what is staged?
Git’s comparison commands inspect different boundaries. git status summarizes both, while the two forms of git diff let you review each comparison directly.
Rank #2
| Command | Comparison | What it shows |
|---|---|---|
git diff |
Working tree versus index | Changes that are not staged. |
git diff --staged or git diff --cached |
Index versus HEAD |
Changes staged for the next ordinary commit. |
git status |
Summarizes both comparisons | Which changes are staged and which remain unstaged. |
In the example above, git status can report both staged and unstaged changes for file.txt: the staged change is the version captured by the first add, and the unstaged change is the later edit. git diff --staged compares that staged version with HEAD; git diff compares the later working-tree version with the index. The Pro Git explanation of the index and three-tree workflow covers these boundaries.
Recommended Free Tools
What does git commit include?
A normal git commit records the state in the index, not every change currently present in your working tree. When committing, Git converts the index’s entries into a tree object and records that tree in the new commit. If you want a later edit included, run git add for it before committing. The git commit documentation describes the staged commit workflow.
Commit only the staged version
- Review staged changes with
git diff --staged. - Run
git committo make a commit from that staged state.
Include a later edit too
- Run
git add file.txtagain to update the index with the current working-tree content. - Review the staged result with
git diff --staged. - Run
git commit.
How can you stage only part of a file?
Use git add -p to review and select individual change hunks instead of staging every change in a file. This can leave some edits staged and others unstaged in the same path. Check the result with git diff --staged for the selected hunks and git diff for changes still outside the index. The git add documentation describes patch mode.
How do you stage removals or handle ignored files?
- Stage additions, modifications, and removals: use
git add -Ato update all of these for the selected paths. - Add an ignored file deliberately: ignored files are not added by default; use
git add -f pathto force one into the index.
These options are documented in the git add reference.
How do you unstage without losing edits?
Run git restore --staged path to restore the index version of that path to the last commit. This removes its staged change from the next ordinary commit while leaving the working-tree copy alone, so your edits remain on disk. Review the result with git status or git diff. The command is documented in the git commit reference.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
What is “intent to add”?
git add -N path records an index entry indicating that the path is intended to be added later, without adding its file content at that time. It is not the same as staging a normal content snapshot. The git add documentation describes this option.
Best Value
What happens to the index during a merge conflict?
While a merge conflict is unresolved, the index can contain multiple entries for the same path at conflict stages 1, 2, and 3. After you resolve the conflict, stage the resolved file so the index has the content intended for the commit. The index entry format and stages are described in Git’s data model documentation.
Further reading
Pro Git, second edition, by Scott Chacon and Ben Straub, is available to read online on the official Git site; the site also notes that print versions are available on Amazon.com.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

