How to Undo Git Add: Unstaging Files Before You Commit
Running git add is one of the most routine actions in a Git workflow — but it's also one of the easiest to do too broadly or too early. Whether you staged the wrong file, included changes you're not ready to commit, or simply want to reorganize what goes into your next commit, Git gives you straightforward tools to undo a git add without touching your actual file contents.
What git add Actually Does
Before undoing anything, it helps to understand what staging means in Git's model.
Git uses a three-stage structure:
- Working directory — your files as they exist on disk
- Staging area (index) — a snapshot of what will go into your next commit
- Repository — the committed history
When you run git add <file>, you're copying the current state of that file into the staging area. You haven't committed anything yet. Undoing git add means removing a file from that staging area — returning it to an "unstaged" state — while leaving the file itself completely untouched on disk.
The Standard Way: git restore --staged
For most users on Git 2.23 or newer, the cleanest command to unstage a file is: