What is the difference between git reset and git revert, and which one is safer for public history and why?
Last updated
git resetrewrites history by moving the branch pointer back, leaving original commits unreachable. On shared branches this forces others to reconcile diverged history.git revertadds a new commit with the inverse changes, keeping history append-only and safe to push normally.Use
resetfor local, unpublished cleanup andrevertfor commits already shared.
- https://www.deployhq.com/git/faqs/difference-git-reset-revert
- https://gnext.dev/guides/git-reset-vs-revert/
- https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting
- https://schacon.github.io/gitbook/4_undoing_in_git_-_reset,_checkout_and_revert.html
- https://dev.to/nguonodave/time-traveling-through-your-repo-git-reset-vs-revert-1en4
- https://medium.com/@vikas.taank_40391/understanding-git-reset-and-git-revert-093408d98313
- https://git-scm.com/docs/git-reset/2.52.0