How to discard local changes or unstage a file (git restore)

Run git restore --staged <file> to unstage a file but keep your edits. Run git restore <file> to throw away your uncommitted changes and go back to the last committed version.

Step by step

  1. Unstage, keep the edits:

    $ git restore --staged README.md
  2. Discard the edits (can't be undone):

    $ git restore README.md
  3. Discard every change in the project:

    $ git restore .

Older guides use git checkout -- <file> and git reset HEAD <file>: they do the same thing.

Try it in the interactive sandbox →Practice “Unstage it” with a real repository and teammates, right in your browser.

Related guides