How it works...

Effectively, we are just changing the pointer of the master branch to point to the previous commit HEAD, which means the first parent of HEAD. Now, the branch will point to 9c7532f, instead of the commit we removed, 35b29ae. This is shown in the following diagram:

The preceding diagram also shows that the original 3061dc6 commit is still present in the repository, but new commits on the master branch will start from 9c7532f; the 3061dc6 commit is called a dangling commit.

You should only perform this undo operation on commits you haven't shared (pushed) yet, since when you create new commits following undo or reset, those commits form a new history that will diverge from the original history of the repository.

When the reset command is executed, Git looks at the commit pointed to by HEAD and finds the parent commit from this. The current branch, master, and the HEAD pointer, are then reset to the parent commit, as are the staging area and working tree.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.70.203