Cheatsheet Pages / Git Cheatsheet

How to discard local changes in a file — git restore (permanent)

Your edits in one file turned out to be a dead end and you want the committed version back.

git restore <file>            # ⚠️ permanently discards unstaged changes in <file>

Good to know

Throws away unstaged edits in one file. There is no undo for this.

Git Cheatsheet one-page card — 30 daily and rescue commands
The full one-page card — Git Cheatsheet. Get the complete cheatsheet on GitHub