Luke M
Git notes
2025-02-26
Cheatsheet
Undoing changes
-
git restore
: Safely undo changes in the working directory or staging area (Git 2.23).git restore <file>
: Discard uncommitted changes in the working directory for a file.
-
git reset
: Alters commit history and/or staging area--soft
: uncommit changes, changes are left staged (index).--mixed
: (default): uncommit + unstage changes, changes are left in working tree.--hard
: uncommit + unstage + delete changes, nothing left.
Footnotes
- [^1] Git rewrite guide
- [^2] Rebasing what can go wrong