Throw away my changes to one file
I changed a file and want it back as it was in the last commit.
The problem
I changed a file and want it back as it was in the last commit.
How the practice repository looked before
## main M notes.txt
83c9caf Add line two 42ed91f Add notes
The fix
Check the result
Why this works
git restore <file> copies the file from the staging area (or the last commit when nothing is staged) over your working copy.
If this is not quite your case
To discard every change in the folder, use git restore . (note the dot). It does not touch untracked files; to remove those, git clean is the command, and it deserves a dry run with git clean -n first. If you are not sure you want to lose the changes, use git stash instead: it is the same cleaning, with a way back.
Be careful: The changes are not in any commit, so they cannot be recovered afterwards.
This is an independent guide. It is not connected with the Git project, GitHub, GitLab or any company named here. Every command below was run on 14 November 2026 with the real program (git version 2.56.0.windows.4) in a new empty practice repository; the output shown is what it printed. Facts about options were read in the official Git documentation on 14 November 2026.