How is git revert
used?
This might sound like a duplicate question but when people ask it, the response is often, use git reset
as per Revert to a commit by a SHA hash in Git?.
Then when someone asks how to use git reset
people reply saying you should use git revert
as per Git - how to rollback.
Before you know it, eight different people appeared with their own unique ways to save the OP's ass, all of which is over your head.
So let’s try and stick the brief and write a Dummies Guide to git revert
.
A scenario: you've committed twice to master and it’s bad. You've pushed and other people have your bad changes.
You want to undo it. It’s not something you can hand-undo in code yourself, say some wizard or package manager changed tons of stuff all over the place - you just want to put it all back how it was.
This is what source control is all about. I'm sure it’s easy.
Okay, you're going to use git revert
, but how?
And after running git revert
, do you have to do something else after? Do you have to commit the changes revert made or does revert directly commit to the repository or what??
Obviously, you'll need to push again and probably announce your balls-up to the team.