Welcome to the git choose your weapon guide. Both git revert and git reset can fix mistakes. One does it politely and leaves a trail for teammates to admire. The other runs around changing history and may cause a panic worthy of a group chat. Use the right tool and avoid awkward stand up meetings.
In plain terms git revert creates a new commit that undoes the effects of a previous commit while git reset moves the branch pointer and optionally rewrites the index and working tree. Revert preserves public history and is safe on shared branches. Reset rewrites history and is best for local cleanup before you push.
--soft
moves the branch pointer only. Good if you want to combine commits into a better commit message or tidy things up before you push.--mixed
moves the branch pointer and resets the index. Your working tree remains, but staged changes are cleared.--hard
moves the branch pointer and resets index and working tree. This one throws away uncommitted changes like it never cared about your late night edits.git revert
git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1
If a commit has already been pushed to a remote prefer revert. Rewriting public history with reset usually forces a push and that can orphan commits and confuse collaborators. In other words be prepared for people to blame the git workflow and not read the README.
Now go forth and fix commits responsibly. And if you do break something at least make it a teachable moment.
I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!
This is a dedicated watch page for a single video.