← Git & GitHub learning pathGit & GitHub · Module 7 of 10
Undoing changes
Fix mistakes safely with Git.
📖 Key ideas
- git restore file discards uncommitted changes.
- git restore --staged file unstages.
- git commit --amend fixes the last commit (before pushing).
- git revert commit creates a new commit undoing changes (safe for shared history).
- git reset moves branches back (careful with shared work).
💡 Real-life example: git revert is writing a correction note; git reset is tearing out pages (dangerous if others have copies).
git restoreDiscards or unstages changes
git revertNew commit that undoes a commit
git resetMoves branch pointer back
--amendModify the last commit