Skip to main content

How to Unstage Files in Git

Short answer

To remove a file from Git's staging area without discarding your local edits, run git restore --staged <file> (Git 2.23+) or the older git reset HEAD <file>. This moves the file back to the 'modified but not staged' state, leaving all your changes intact in the working directory. To unstage every file at once, use git restore --staged . or git reset HEAD. This is a completely safe operation — no work is lost, and you can re-stage the file any time with git add. Use git status before and after to verify which files are staged, and git diff --cached to review the exact changes queued for the next commit.

Git has a concept called "Staging Area" to determine which changes should go into the next commit. And it's important to understand that changes are NOT added to the Staging Area automatically: they have to be manually and explicitly added with the git add command. Adding files to the Staging Area like this is often called "staging files for the next commit."

In this short article, we'll discuss how to do the opposite: how to unstage a file in Git, i.e. removing it from the Staging Area to prevent it from being included in the next commit.

The Git Cheat Sheet

No need to remember all those commands and parameters: get our popular "Git Cheat Sheet" - for free!

Free. We email you a ZIP with our cheat sheets.


Using git restore to Unstage

The git restore command is perfect when you have already added a file to the Staging Area and then changed your mind:

git restore --staged myFile.js

This will remove the file from the Staging Area, making sure that it will NOT be part of the next commit.

In case you also want to discard the local changes in this file, you can simply remove the --staged option:

Careful: this command can discard work.

git restore index.html

This will discard any local modifications in this file and reset it to its last committed state. Please be very careful with this command: discarding uncommitted local changes cannot be undone!

No Command Line Needed

Unstaging files in Tower

In case you are using the Tower Git client, unstaging a file is as simple as unchecking its "Status" checkbox in the Working Copy view:

Using git reset to Unstage

Apart from restore you can also use git reset to unstage changes. If you're using a Git version older than 2.23, you will have to use reset because restore is quite a new feature in Git.

git reset myFile.js

Exactly like git restore --staged, this makes sure the file is NOT included in our next commit. The local changes themselves are not affected by this command.

Unstaging All Files at Once

Sometimes, you might want to unstage all of the files you had already added to the Staging Area. In such a situation, you can use git reset without further options:

git reset

The Staging Area will be emptied (but your local changes themselves are left untouched).

Learn More

Free download

Download the Cheat Sheet

Get 18 of our most popular Cheat Sheets in one handy ZIP!