The short answer: run git restore --staged . from the repository root. That command copies every staged path back to its state in HEAD, so the files stay on disk with their edits but drop out of the index. If the repository has no commits yet, use git rm --cached -r . instead, since there's no HEAD to restore from. Both commands change the index only, never your working tree. The one case that breaks this pattern is newly created files, which become untracked and therefore invisible to git diff after unstaging. You haven't deleted work, but you should know where it went before you react.

Everything below assumes a normal repository with at least one commit, notes the older syntax for Git versions before 2.23, and covers the situations where the simple command isn't enough.

Prerequisites and the One-Minute Version

Before touching the index, confirm where you stand. Three commands give you the full picture:

1: git status shows which files are staged, which are modified but unstaged, and which are untracked. 2: git diff --cached --stat lists exactly what is staged, with line counts per file. 3: git rev-parse --verify HEAD tells you whether a commit exists. If it fails, you're in a fresh repository and the main recipe won't apply.

Then, from any directory inside the work tree:

1: Run git restore --staged . to unstage everything. The . pathspec means "all paths under the current directory," and run from the root it covers the whole repository. 2: Run git status again. Every previously staged change should now appear under "Changes not staged for commit," and newly created files should appear under "Untracked files." 3: Run git diff to confirm your edits are intact in the working tree.

Success looks like an empty "Changes to be committed" section with nothing lost from the file contents. If the staged list is empty afterward but your edits are gone from the files too, you used a working-tree-discarding command by mistake, which is a different recovery problem addressed below.

git restore --staged arrived in Git 2.23, released in 2019. On older installations, git reset is the equivalent and still works today: git reset with no arguments unstages everything, and git reset HEAD -- . does the same explicitly. The two forms differ in one respect covered in the next section: git reset has a --hard mode that destroys working-tree changes, and muscle memory around that flag is a common source of accidents. git restore --staged has no such mode by design.

What "Staged" Actually Means, and Why Unstaging Is Safe

Git tracks your work in three places. The working tree is the files you edit. The index, also called the staging area, is a prepared snapshot of what the next commit would contain. HEAD is the last commit on the current branch. Staging copies a file's current content into the index; committing turns the index into a new commit.

Unstaging reverses that copy. It rewrites the index entry to match HEAD while leaving the working tree alone. That's why the operation is safe for edits: the bytes on disk don't move. The nuance is that the index and the working tree are separate, so a staged new file loses its index entry and becomes untracked, and a staged deletion of a tracked file reverts in the index, making the file appear again as an unstaged deletion.

A concrete example makes the distinction tangible. Suppose you edit app/config.py, stage it, then edit it again without staging. The index holds the first version; the working tree holds the second. Running git restore --staged app/config.py sets the index back to the committed version, and both of your edits survive on disk as unstaged changes. git diff --cached now shows nothing for that file; git diff shows both edits.

Recipe 1: Unstage Everything in a Repository With Commits

This is the standard case the query describes. Preconditions: you're inside the repository, a commit exists, and you want every staged path returned to its HEAD state.

1: Optionally save a snapshot first: git stash push --staged creates a stash containing only the staged changes, which is a cheap insurance policy if you're about to reorganize a large index. Skip it if you're confident; it's not required. 2: Run git restore --staged . from the repository root. To be explicit about the source, git restore --staged --source=HEAD -- . does the same thing. 3: Check with git status --short. Staged entries show in the first column; after the command, that column should be blank for every file. 4: Verify content preservation with git diff --stat for tracked changes and git status for untracked additions.

Older Git: git reset with no pathspec unstages everything and touches nothing on disk. git reset HEAD -- . is the verbose equivalent. Both behave identically to the restore form for this purpose.

A frequent variant is partial unstaging. Running git restore --staged src/ limits the operation to one directory, and git restore --staged app/config.py handles a single file. Pathspecs follow normal Git globbing, so git restore --staged '*.log' works with quoting to protect the pattern from the shell.

Recipe 2: The First Commit Doesn't Exist Yet

In a fresh repository, HEAD points to an unborn branch. There's no committed state to restore from, so git restore --staged . fails with a message about an invalid reference. The goal changes slightly: every staged file should return to untracked status.

1: Confirm the situation with git rev-parse --verify HEAD, which exits nonzero. 2: Run git rm --cached -r . to remove everything from the index recursively while leaving files on disk. The --cached flag is the critical part; without it, git rm deletes files from the working tree as well. 3: Run git status and confirm all files now appear as untracked. 4: Re-add only what you actually want with git add and pathspecs, since a blanket add is presumably what created the mess.

The same git rm --cached approach handles the "I accidentally committed build artifacts or a large data file" case even after commits exist. git rm --cached path/to/file unstages the file and, once committed, stops tracking it while keeping your local copy. Add the path to .gitignore in the same commit so it doesn't reappear.

Recipe 3: Recover After a Mistaken git reset --hard or git restore --worktree

The dangerous commands are the ones that write to the working tree. git reset --hard resets the index and the working tree to a commit, discarding uncommitted edits. Plain git restore file (without --staged) overwrites the working-tree copy from the index. If either ran by accident, the index-based recipes above can't help because the content itself moved.

Recovery depends on where the content still exists:

1: If the changes were staged at any point in the last 30 days, check git fsck --lost-found --unreachable for dangling blobs, which are the staged snapshots Git wrote but no longer references. git cat-file -p prints the contents, which you can redirect into the file. This works because staging writes a blob object immediately. 2: If you stashed before resetting, git stash list followed by git stash apply restores it. 3: If the content was committed and then a reset moved the branch, git reflog shows the previous HEAD positions; git reset --hard HEAD@{n} returns to one of them. 4: If an editor still has the file open with unsaved content, saving from the editor is often the fastest path.

A stop condition belongs here: if the lost work was never staged, never stashed, and never committed, Git has no record of it, and further fiddling risks overwriting recoverable state. At that point, stop and restore from your editor's local history, an OS-level backup, or your file-sync service's version history rather than improvising more Git commands.

Choosing Between git restore, git reset, and git checkout

The three commands overlap, and the differences matter mostly for safety and for older installations.

Command What it changes Working tree risk Notes
git restore --staged . Index only None Git 2.23+, recommended form
git reset (no pathspec) Index only, resets to HEAD None Works in all versions
git reset --hard Index and working tree Destroys uncommitted edits Avoid unless intended
git reset -- Index entry for path only None Useful for restoring a single path to an older commit
git checkout -- Working tree from index Overwrites unstaged edits Old syntax; git restore replaces it

The rule of thumb: use restore --staged for index work, and reserve reset for moving branch pointers. The single-path form git reset -- has one genuinely useful trick: it lets you unstage a file back to a specific older commit rather than HEAD, which is handy when you staged a file from the wrong branch state. git restore --staged --source= -- does the same in modern syntax.

After Unstaging: Finding New Files, Re-Staging Selectively, and the git add -A Trap

Newly created files are the most common surprise after a blanket unstage. They don't vanish, but git diff won't show them because they're untracked. git status lists them under "Untracked files," and git add -N registers an intent-to-add entry so git diff includes their content without staging it for commit.

Re-staging selectively is where interactive tools earn their place. git add -p walks through hunks and lets you stage some and skip others. git restore --staged combined with git add -p is a clean workflow for splitting a messy index into focused commits.

The trap worth naming: git add -A or git add . followed by a broad unstage and another git add -A tends to reproduce the same index, including files you meant to exclude. If the original mess came from adding build output, credentials, or large binaries, fix the source by adding patterns to .gitignore before re-adding. An already-tracked file ignores .gitignore until you git rm --cached it, which is why the order matters.

Edge Cases and How They Behave

Staged deletions. If you ran git add on a deleted file, unstaging restores the index entry and the file appears as an unstaged deletion. To accept the deletion, git rm it; to cancel it, git restore from HEAD.

Merge conflicts. During a conflicted merge or rebase, git restore --staged is unreliable for conflicted paths because the index holds multiple stages. git restore --staged --ours or --theirs selects one side, and git reset -- clears the conflict state back to the unmerged entry. git merge --abort or git rebase --abort is the cleaner exit if you want out entirely.

Untracked files inside the pathspec. git restore --staged . doesn't touch them; they were never in the index. That's why a file count can look wrong after unstaging, since a staged addition and an untracked file are the same thing from the index's point of view.

Submodules and sparse checkouts. A parent repository records a submodule as a single gitlink entry, and unstaging works normally on that entry. In a sparse checkout, paths outside the sparse cone may not exist on disk, so unstage specific paths rather than relying on a blanket . if you see unexpected results.

Case-only renames on case-insensitive filesystems. A file renamed only by letter case can behave oddly after unstaging on macOS or Windows. If the rename seems to have reverted, re-add it and commit the rename in one step.

An empty result. If git restore --staged . appears to do nothing, check whether you're in a subdirectory whose pathspec covers nothing staged, or whether another process or a hook is re-adding files. git status from the root resolves the first; checking .git/hooks resolves the second.

A Safe Order of Operations for Real Repositories

A repeatable sequence that keeps the index honest:

1: Run git status and git diff --cached --stat to see the damage. 2: Decide whether the goal is "unstage everything" or "unstage these paths." Pathspecs are always safer and faster. 3: Unstage with git restore --staged , or git reset on older Git. 4: Verify with git status --short and git diff --stat. 5: Fix the cause if the mess came from generated files: update .gitignore and git rm --cached anything already tracked. 6: Re-stage deliberately, favoring git add -p for mixed changes. 7: Commit in logical units so the index never accumulates a second pile of unrelated work.

None of these steps requires network access, and none rewrites history. The whole operation is local index bookkeeping, which is why it's safe to run and easy to repeat if the result isn't what you expected.

Questions That Come Up Often

Does unstaging delete my edits? No. The index and working tree are separate; git restore --staged and git reset without --hard write only to the index. Your edits stay on disk as unstaged changes.

Where did my new files go after unstaging? They became untracked. git status lists them, and git add brings them back. Nothing was deleted.

Can I unstage just one file or one hunk? Yes. Pass a pathspec for the file, or reset the file and use git add -p to re-stage only the hunks you want.

What if I have no commits yet? git rm --cached -r . empties the index while keeping every file on disk. From there, re-add what you want with git add.