
GIT RESET HEAD UPDATE
To update the HEAD pointer to reset the Index, run git reset with -mixed or without an option: git reset -mixed HEAD~1 git reset HEAD~1 If you run the git status command, you’ll see that the changed files are listed as uncommitted changes. The command above moves the current branch backward by one commit, effectively undoing your last commit. HEAD~1 is a variable that points to the previous commit. To undo the last commit without losing the changes you made to the local files and the Index, invoke git reset with the -soft option followed by HEAD~1: git reset -soft HEAD~1 Be extra careful when using this option as all local changes you haven’t committed will be overwritten and lost.

The git reset command has three arguments that correspond to the three trees: The HEAD - A pointer to your last commit on the current branch.It is often referred to as “staging area” or “staging index”. The Index - This tree keeps track of new or changed files that have been added to the index with git add, to be included in the next commit.The working directory is something like a sandbox where you can test the changes before committing them to the staging index. It is often referred to as a “working tree”. The Working Directory - A directory, including all subdirectories and files on the local filesystem that is associated with the repository.Git manages and manipulates the following three trees: They are called trees because they represent collections of files. Three-tree architecture is the key concept of the Git management system. To better understand how reset works let’s talk about the Git’s three different trees.

Git reset takes additional arguments that allow you to control the command behavior. In Git you can undo changes using the git reset command followed by the commit identifier. If you only want to change the commit message, check out this article It is not recommended to undo a commit is already pushed to a shared repository.
GIT RESET HEAD HOW TO
This guide explains how to undo the last Git commit. To undo a commit, all you need to do is point the HEAD variable to the previous snapshot. Git has a reference variable called HEAD that points to the latest commit in the current working branch. A commit is a snapshot of a Git repository at a given time. Sometimes, when working with Git, you may want to undo the latest commit.
