All fixes

Help, I want to throw away my changes to a file

Get a file back to how it was in your last commit and start over, for one file or all of them.

What Git says~/my-app
git status
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   index.html

The fix

  1. git restore index.html

    Throws away your unstaged edits to this file. There is no undo for edits that were never committed.

    Discards uncommitted changes

index.html is an example. Replace it with your own.

Why this works

git restore copies the file back from the staging area, which matches your last commit unless you staged something. Already staged the change? git restore --staged --worktree index.html goes all the way back to the last commit. git restore . does this for every tracked file. New, untracked files are not touched by any of this: git clean -nd lists them and git clean -fd deletes them.