How to Undo git add (Unstage Files)
Staging a file does not commit it; it selects the changes Git will include in your next commit. If you staged the wrong file or need to adjust a commit, you can unstage it and keep your working edits. Check what is staged before changing the index.
Practice Git workflows →Check what is staged
First inspect the repository status and the staged diff:
git status
git diff --stagedgit diff --staged shows the changes prepared for the next commit. Review it to make sure you identify the right file and content before unstaging.
Unstage one file
Use git restore --stagedfollowed by the path to remove that file's staged snapshot from the index:
git restore --staged -- path/to/fileThis changes what is staged, not the file in your working tree. Your edits remain available to review, modify, or stage again. Keep the -- separator before the path; it helps distinguish a filename from a command option.
Unstage multiple files or everything
Name several paths to unstage only those files:
git restore --staged -- src/file-a.js docs/guide.mdTo unstage all currently staged changes in the current repository, use:
git restore --staged -- .The period means the current directory and its descendants. Use the all-files form only when you intend to unstage every staged change; check git status afterward.
Unstage only part of a file
If only some hunks in a file should be removed from the index, use interactive patch mode:
git restore --staged --patch -- path/to/fileGit presents staged hunks for you to review and choose. Because patch mode can be confusing when changes overlap, read each prompt and inspect both the staged and unstaged diffs afterward.
Verify the result
After unstaging, inspect the index and working tree separately:
git status
git diff --staged
git diffThe staged diff should no longer contain the unstaged changes. Depending on whether the file also differs from the last commit, those edits may appear in git diff instead. Nothing is committed by these commands.
What if the file is newly created?
The same command works for a newly created file that was staged with git add. Unstaging removes it from the index but leaves it in your working directory as an untracked file. If you want to remove it from your computer, delete it separately only after confirming you no longer need it.
Unstaging FAQ
Does unstaging a file delete my changes?
No. git restore --staged removes the selected snapshot from the staging area and keeps the working-tree file. Avoid using git restore without --staged when you mean to keep the edits; that command can replace working-tree content.
Can I use git reset to unstage a file?
Yes. git reset HEAD -- path/to/file is a familiar alternative for unstaging a path. On modern Git, git restore --staged communicates the intent more clearly.