Git & GitHub · Lesson 32 of 144
Reset or Revert?
Choosing the right undo.
So you have two ways to undo a commit. Which one should you use? There's one simple question that decides it.

- Two ways to undo a commit
- Which one?
- One simple question
Have you shared it?
Ask yourself, have I pushed this commit, so others might have it? If yes, use revert. It adds an undo commit, and nobody's history breaks. If no, the commit is only on your computer, you can use reset, and keep your history tidy.
Already shared?
- Use git revert
- Adds an undo commit
- Nobody's history breaks
Only on your computer?
- git reset is fine
- Rewrites your history
- Keeps it tidy
Quick check
Quick check. You pushed a bad commit to GitHub yesterday, and your team has pulled it. How should you undo it? Reset dash dash hard, revert, or amend? The answer is revert. The other two rewrite history your team already has.
Quick check
A bad commit is already on GitHub, and your team has it. How do you undo it?
Summary
Shared commits get reverted. Private commits can be reset. Next, how Git can rescue you even after reset dash dash hard.
Key takeaways- Shared: revert
- Private: reset
- When unsure: revert
Next up: The Safety Net — git reflog