Undo git add: Unstage Files Safely (Complete Guide for 2026)

Published February 16, 2026 · 8 min read

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.

⚙ Quick links: Git Restore (full guide) · Git Reset (soft/mixed/hard) · Undo Last Commit in Git · Git Undo Decision Guide · Git Diff · Git Commands Cheat Sheet

Table of contents

  1. Copy/paste recipes
  2. What changes when you undo git add
  3. git restore --staged (recommended)
  4. git reset HEAD (legacy equivalent)
  5. Common scenarios
  6. restore vs reset vs checkout
  7. FAQ

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 -- .
Tip: Verify exactly what is staged before and after with git status and git diff --cached.

2. What changes when you undo git add

Git has three important areas:

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.

Warning: Avoid 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.

Related Resources

Git Restore Complete Guide Deep dive on restore, source commits, and patch mode. Git Reset Complete Guide When you need to undo commits, not just staging. Git Undo Decision Guide Pick reset vs revert vs restore quickly and safely. Git Commands Cheat Sheet Quick command reference for daily Git workflows.