Reverting changes allows you to undo the effects of a commit by creating a new commit that reverses the changes. This is a safe way to undo changes in a shared repository because it preserves the history.
If you realize a bug was introduced in commit abc123
, you can revert it by running:
git revert xyz321
This will create a new commit that undoes the changes made by commit xyz321.
Use git revert
when you want to undo a commit but still keep a record of the original changes. This is especially useful in collaborative environments where other people might have already pulled the changes.