The "oh no" button: undo, revert, reset
This is the part that turns from a chore into a superpower. When something goes wrong — and it will — here's how to walk it back.
- Throw away unsaved changes — you edited (or the AI edited) some files and made things worse, but you haven't committed yet. You can discard everything back to your last good .
- Revert a commit — you saved a change, then realized it was bad.
git revertcreates a new commit that undoes the bad one, keeping your history honest. - Reset to an earlier point — you want to rewind your project to how it was several commits ago.
# Undo all uncommitted changes and go back to your last commit
git restore .
# Safely undo a specific bad commit (creates a new "undo" commit)
git revert <commit-id>
# Rewind to an earlier commit (powerful — ask the AI to explain before using)
git reset --hard <commit-id>
A word of caution: git reset --hard permanently discards work. It's the right tool sometimes, but the one to be careful with. When unsure, ask the AI "what exactly will this command do to my files?" before running it.