Undo git add: Unstage Files Safely (Complete Guide for 2026)
If you staged the wrong file, wrong hunk, or just ran git add . too early, you need to undo git add without losing your edits. This guide gives you the exact commands for one file, multiple files, and all files.
The short version: use git restore --staged. It removes files from the staging area but keeps your local changes in the working directory.
Table of contents
1. Copy/paste recipes
Undo git add for one file
git restore --staged path/to/file
Undo git add for all staged files
git restore --staged .
Undo git add and keep editing
git restore --staged src/app.js
# file is now unstaged, local edits are still there
Undo git add and discard local edits too (destructive)
git restore --staged --worktree src/app.js
Older Git fallback
git reset HEAD -- path/to/file
# unstage all
git reset HEAD -- .
git status and git diff --cached.
2. What changes when you undo git add
Git has three important areas:
- HEAD: latest commit snapshot
- Index (staging area): what will go into your next commit
- Working tree: your current file edits
Undoing git add should usually change only the index, not your working tree files.
| Command | Index | Working tree |
|---|---|---|
git restore --staged file |
Unstage | No change |
git reset HEAD -- file |
Unstage | No change |
git restore --staged --worktree file |
Unstage | Discard edits |
3. Use git restore --staged (recommended)
git restore --staged is the modern, explicit way to unstage files. It is clearer than git reset when your goal is only to undo git add.
# unstage one file
git restore --staged README.md
# unstage multiple files
git restore --staged README.md src/main.py
# unstage everything
git restore --staged .
For partially staged files, this unstages the staged hunks and keeps your edits in place.
4. git reset HEAD is the older equivalent
Before git restore existed, most guides used:
git reset HEAD -- path/to/file
This is still valid. The behavior for unstaging is similar, but git reset has many other modes and can rewrite history, so it is easier to misuse. For pure unstaging, prefer git restore --staged.
git reset --hard when you only need to unstage files. --hard can delete uncommitted work.
5. Common scenarios
I ran git add . and staged too much
git restore --staged .
# then stage only what you need
git add src/important-file.js
I want to unstage, edit, then recommit
git restore --staged src/app.js
# edit src/app.js
git add src/app.js
git commit -m "Refine change"
I accidentally staged a secret file
git restore --staged .env
# if needed, also delete local edits
git restore .env
If a secret was already committed or pushed, unstaging is not enough. Follow your secret-rotation process immediately.
6. restore vs reset vs checkout
| Task | Recommended command |
|---|---|
| Undo git add (unstage only) | git restore --staged <path> |
| Undo local file edits | git restore <path> |
| Undo local commits | git reset (soft/mixed/hard as needed) |
| Legacy unstage command | git reset HEAD -- <path> |
7. FAQ
Does undoing git add delete my changes?
No, not with git restore --staged or git reset HEAD -- file. Those commands only unstage files.
How do I see what is staged right now?
Run git status for a summary and git diff --cached for exact staged diffs.
Can I unstage only part of a file?
Yes. Use git restore --staged --patch file (or git reset -p file) to interactively select hunks.
Why does Git still show changes after I unstaged?
Because unstaging does not revert file content. Your edits remain in the working tree until you commit, stash, or restore them.
Should I still learn git reset if restore exists?
Yes. git reset is essential for commit-history operations. For file-level unstaging, git restore --staged is the clearer default.