Need Assistance?

support@tutorialshub.in

Undoing Changes and Rewriting History

Revert a published commit

ADVERTISEMENT
Git Free Lesson
5 min read
ADVERTISEMENT

Revert creates an undo commit

git revert creates a new commit whose change reverses an earlier commit. This is the preferred approach for undoing changes that have already been shared on a branch where history should remain stable.

Why revert is safer for shared history

Because the original commit remains in history, other developers do not have to rewrite their local copies of the branch. The repository records both the original change and its later reversal.

Reverting a merge

Reverting a merge commit requires choosing the mainline parent because a merge has multiple parents. This should be done carefully and tested because the result affects a whole integration.

ADVERTISEMENT