This command clears files from the staging area so you can review or adjust your staged changes before committing.
The --staged
flag tells Git to update only the index by moving specified files out of the staging area instead of modifying the working directory, effectively undoing a git add
; you can follow this with one or more file paths or glob patterns to target particular files or directories.
Variants and related commands: use git restore --staged <file>
to unstage a specific file or git restore --staged .
to unstage all changes; alternatively, git reset HEAD <file>
or git reset -- <file>
offers similar unstage behavior; for removing files from tracking without deleting them you can also use git rm --cached <file>
.