Unstage a File
git restore --staged <file>Removes a file from the staging area but keeps your changes.
To unstage a file in Git without discarding its working-tree edits, run git restore --staged <file>. For example, git restore --staged -- src/app.js unstages src/app.js; replace that example path with your file path.
git restore --staged <file>git restore --staged <file>Removes a file from the staging area but keeps your changes.
With --staged and no --source option, Git restores the selected path in the index (staging area) from HEAD, the current commit. It leaves the working-tree file and its edits alone. Those edits are no longer staged for the next commit; the file is not deleted from your working tree. This default requires an existing HEAD commit, so it is not the same first-commit workflow in a repository with no commits.
git restore --staged -- src/app.js changes the index only. By contrast, git restore -- src/app.js restores the working-tree file from the index by default and can discard its unstaged edits. Without --staged, the default source is the index, not necessarily HEAD. Adding --worktree together with --staged would also change the working file; do not add it when you intend only to unstage.
Check the unstaged differences before deciding what to stage again. Treat the discard-file-changes task separately: it can lose edits and is not an alternative way to unstage.
Run git restore --staged <file>.
Run git restore --staged <file>.
Type it in the terminal or command-line interface used by Git.
Yes. The command text is the same on both platforms when the tool is installed.