How it works...

Again, Git will reset the branch pointer and HEAD to point to the previous commit. However, with the --soft option, the index and working directories are not reset, that is, they have the same state as they had before we created the now undone commit.

The following diagram shows the Git state before and after the undo:

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.