Git, AI Tools & Your Career / Git and GitHub
Lesson 11 of 32
Undoing changes
git restore throws away uncommitted edits to a file, and git revert makes a new commit that undoes an old one. Revert is safe on shared branches because it doesn't rewrite history.
Key points
- git restore file: drop local edits
- git revert <commit>: undo safely
- Avoid rewriting shared history
git restore app.py
git revert a1b2c3dQuiz · +10 XP
Which command safely undoes a commit that's already been pushed?
Log in to save progress and earn XP.