--staged
A flag that points a command at the staging area instead of the working tree, as in git diff --staged or git restore --staged.
In more detail
git diff --staged compares the staging area with the last commit, showing what the next commit will contain. For git diff it is a synonym of the older --cached.
Example
git diff --staged --statRelated terms
- staging area — Git's list of exactly what the next commit will contain, kept in the file .git/index; also called the index.
- git diff — The command that shows the differences between two of Git's states: the working tree, the staging area, or any two commits.
- git restore — The command that throws away uncommitted changes to a file, or with --staged takes a file back out of the staging area.
Taught in
- The Three Areas: Working Tree, Index, Repository — Advanced Git Internals & Distributed Workflows
- Staging Deliberately: status, add, add --patch — Advanced Git Internals & Distributed Workflows
- Reading History: log, show And diff — Advanced Git Internals & Distributed Workflows
- Undoing: restore, reset, revert And stash — Advanced Git Internals & Distributed Workflows