Cheat Sheets · Git Cheat Sheet · Git Unstage File — Remove from Staging Area
Git Unstage File — Remove from Staging Area
git restore --staged <file>>= 2.23 (Modern)
git restore --staged .>= 2.23 (Modern)
git reset HEAD <file>< 2.23 (Legacy)
Unstaging commands
| Command | Git Version | Effect |
|---|---|---|
git restore --staged <file> | >= 2.23 (Modern) | Unstage specific file; keep local changes intact |
git restore --staged . | >= 2.23 (Modern) | Unstage all staged files at once |
git reset HEAD <file> | < 2.23 (Legacy) | Classic command for unstaging; identical effect |
Accidentally ran git add on the wrong file? Unstaging removes the file from the index (staging area) while preserving all your edits in the working directory.
Related Git recipes
FAQ
Will unstaging delete my edits?
No! Unstaging only removes the file from the upcoming commit. Your working tree edits remain 100% intact.
How do I discard the edits entirely?
Run git restore (without --staged) to revert working directory changes to HEAD.
What is the difference between git restore --staged and git rm --cached?restore --staged keeps the file tracked in Git. rm --cached stages the file for complete removal from Git tracking.
Stop memorizing — build it interactively
Build staging workflows in the Git BuilderFull reference: Git Cheat Sheet