Undoing Things Safely
git revert
The safe way to undo commits that are already pushed or in production.
git reset
--soft, --mixed, and --hard: know what each one destroys.
git reflog
Your safety net. Almost nothing is truly lost.
git restore and git switch
The modern replacements for the overloaded checkout.
git commit --amend
Fix up the most recent commit.
git push --force-with-lease
Use --force-with-lease, never plain --force.
Next TopicCollaboration & Code Review