How does git revert differ from git reset?
⚡
Quick Answer
revert creates a new commit that undoes a previous one (safe on shared branches); reset moves the branch pointer (rewrites history).
Detailed Answer
On a shared branch, use revert — it adds a commit reversing the target, so history stays intact and pushable. reset rewrites history and requires a force-push, which disrupts collaborators. Reach for revert in public branches, reset only on local/private work.
💡
Interview Tip
revert for public branches, reset for private.
gitrevertreset