We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Revert vs. Reset

  • git reset --soft: Undo commits but keep changes staged
  • git reset --hard: Undo commits and discard changes
  • git revert: Create a new commit that undoes a previous commit

When to Reset

If you're working on your own branch, and you're just undoing something you've already committed, say you're cleaning everything up so you can open a pull request, then git reset is probably what you want.

When to Revert

However, if you want to undo a change that's already on a shared branch (especially if it's an older change), then git revert is the safer option. It won't rewrite any history, and therefore won't step on your coworkers' toes.

Click to play video