Command

Git Discard File Changes Command

The Git command to discard file changes is git restore <file>.

Quick Answer

Command
git restore <file>
GitCommand

Discard File Changes

Type this command
git restore <file>

Discards uncommitted changes to a file.

Tip: This permanently loses the uncommitted changes in that file.

Learn More

How to discard file changes in Git

  1. Open the terminal or command interface for Git.
  2. Type git restore <file>, replace any placeholders, and run it.

Tip: This permanently loses the uncommitted changes in that file.

Git Discard File Changes Command

Run git restore <file>.

Related Commands

Frequently asked questions

What is the Git command to discard file changes?

Run git restore <file>.

Where do I type this Git command?

Type it in the terminal or command-line interface used by Git.

Does this Git command work on Mac and Windows?

Yes. The command text is the same on both platforms when the tool is installed.

Official source · How we verify