Reverting a Commit in the Middle

In this episode, we're going to use the “git revert” command. Revert is perfect for cases where you want to undo the effects of an old commit.

Transcript
Reverting a Commit in the Middle

In this episode, we’re going to use the “git revert” command. Revert is perfect for cases where you want to undo the effects of an old commit - like in this example. Let’s say you wanted to undo “C2”, then revert would create a new commit that contains the opposite changes.

This is important to understand: revert does not delete any commits. Instead, Git automatically creates a new commit with changes that revert the effects of the unwanted commit.

Let’s look at a practical example and assume that we want to undo that “Change headlines” commit here. We can simply right-click the commit and select “Revert” from the menu.

That’s already it - we have now successfully reverted an old commit with a new one.