What is the difference between git revert and git reset?
Follow:
Comman
Description Safe for shared
repos?
git revert Creates a new commit that undoes changes from a
previous commit
✅ Yes
git reset Moves the branch pointer back to a previous commit,
potentially removing commits
❌ No (rewrites
history)
Example:
If you realize a commit caused an error:
- git revert will make a new commit that undoes it.
- git reset will erase it as if it never happened (good for local cleanup).