Discard unstaged changes in Git

David Y.

The Problem

How can I discard all unstaged changes in my Git repository?

The Solution

We can do this using git restore. To discard changes for all files in our current working directory run the following:

git restore .

To discard unstaged changes for a specific file, run the following:

git restore path/to/file
Join the discussionCome work with us
Share on Twitter
Bookmark this page
Ask a questionImprove this Answer

Related Answers

A better experience for your users. An easier life for your developers.

    TwitterGitHubDribbbleLinkedin
© 2023 • Sentry is a registered Trademark
of Functional Software, Inc.