How it works...

From the parent commit pointed to by the commit at HEAD, Git resets the branch pointer and HEAD to point to the parent commit. The staging area is reset, but the working tree is kept as it was before the reset, so the files affected by the undone commit will be in a modified state. This is illustrated in the following diagram:

The --mixed option is the default behavior of git reset, so it can be omitted: git reset HEAD^

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.