Guided Notes

Undoing Changes

Discarding edits, amending commits, reverting safely, resetting history, and recovering with reflog.

Undoing before you commit

Slide 1 / 5

git restore index.html β€” throw away unstaged edits to a file (they can't be recovered). git restore --staged index.html β€” unstage a file, keeping the edits. git clean -n β€” list untracked files; git clean -f deletes them.

When in doubt, run git status first β€” it prints the exact commands to undo each kind of change.

← Collaborating on GitHub