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
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.
Course outlineEpisode 6 of 17
- Discarding All Local Changes in a File
- Restoring a Deleted File
- Discarding Chunks / Lines in a File
- Discarding All Local Changes
- Fixing the Last Commit
- Reverting a Commit in the Middle
- Resetting to an Old Revision
- Resetting a File to an Old Revision
- Recovering Deleted Commits
- Recovering a Deleted Branch
- Moving a Commit to a New Branch
- Moving a Commit to a Different Branch
- Editing Old Commit Messages
- Deleting Old Commits
- Squashing Multiple Commits into One
- Adding a Change to an Old Commit
- Splitting / Editing an Old Commit