Skip to content

Unstaging Files

You ran git add on the wrong file, or staged changes you are not ready to commit, or realized you want to split your staged work into two separate commits. Unstaging lets you remove a file from the staging area without touching your working tree — the changes are preserved, just no longer queued for the next commit.

Terminal window
git restore --staged pine-ridge.txt

The file is removed from the staging area. Your working-tree changes to the file are untouched. git status will now show the file under “Changes not staged for commit” instead of “Changes to be committed.”

To unstage everything at once:

Terminal window
git restore --staged .

Unstaging does not:

  • Delete your working-tree changes (your edits are still in the file)
  • Revert the file to any previous version
  • Touch any committed history

It only removes the file from the staging area. The change moves from “about to be committed” back to “modified but not yet staged.”

You have been working and ran git add . without thinking. Now you have several files staged but you want to commit them separately — a bug fix in one commit, a new feature in another.

Terminal window
git status
Changes to be committed:
modified: index.html
modified: styles.css
modified: main.js

You want index.html and styles.css together (they are both part of the bug fix), but main.js belongs in a separate feature commit.

Unstage main.js:

Terminal window
git restore --staged main.js

Now commit the bug fix:

Terminal window
git commit -m "Fix hero image height on mobile"

Stage and commit the feature:

Terminal window
git add main.js
git commit -m "Add scroll-triggered card reveal"

The staging area is the tool that made this possible.

Before git restore --staged existed, the command was:

Terminal window
git reset HEAD pine-ridge.txt

HEAD is the current commit. This form of git reset is called a “mixed reset” scoped to a single file — it moves the file out of the staging area without touching the working tree. You will still see it in older documentation and Stack Overflow answers. Both work.

CommandEffect on working treeEffect on staging area
git restore --staged <file>NoneRemoved from staging
git reset HEAD <file>NoneRemoved from staging

They produce the same result. git restore --staged is the recommended modern form.

  1. In your git-practice folder, make changes to two files — pine-ridge.txt and summit-challenge.txt.

  2. Stage both:

Terminal window
git add .
  1. Run git status to confirm both are staged.

  2. Unstage summit-challenge.txt:

Terminal window
git restore --staged summit-challenge.txt
  1. Run git status again. Confirm pine-ridge.txt is still staged and summit-challenge.txt is back in the unstaged section.

  2. Open summit-challenge.txt and confirm your changes are still there — unstaging did not remove them.

  3. Commit only the staged file:

Terminal window
git commit -m "Update Pine Ridge visit timing"

Then stage and commit summit-challenge.txt separately with a different message.

  • git restore --staged <file> removes a file from the staging area without affecting working-tree changes.
  • git restore --staged . unstages everything.
  • Unstaging is not destructive — your edits are preserved in the working tree.
  • Use unstaging to split staged changes into separate commits.
  • The older equivalent is git reset HEAD <file>. Same behavior, still valid.

Next: amending the last commit — how to fix the commit message, add a forgotten file, or make small corrections immediately after committing.