Undo Changes in Git

From the Git cheat sheet · Fixing Mistakes · verified Jul 2026

Undo Changes

Revert uncommitted changes in your working directory

bash
# Discard changes to a file (modern, Git 2.23+)
git restore <file>
git restore .             # All files

# Unstage a file (keep edits)
git restore --staged <file>

# Older equivalents
git checkout -- <file>
git reset HEAD <file>

# Nuke all local changes
git reset --hard HEAD
git clean -fd             # Remove untracked files/dirs
💡 git restore is the modern verb for files (Git 2.23+)
⚠️ --hard reset and clean -fdx are destructive — no undo
✅ Always git status first to confirm what you are discarding
📌 Soft reset keeps changes for recommit

More Git tasks

Back to the full Git cheat sheet