GIT HEAD and its Importance

Git Head, refers to the most recent commit either to the trunk or to a branch. HEAD names the commit on which you based the changes in the working tree.

In Git you can refer to your current branch or commit by the special reference HEAD in place of the branch name or commit reference. When you change branches, HEAD is updated to refer to the new branch’s latest commit.

If you are not currently on a branch because you have checked out a specific commit but not any particular branch then Git Extensions will show (no branch) in place of a branch name in the toolbar. This is called “Detached HEAD

Cases where HEAD is applied

#Move the branch pointer back to the previous HEAD

git reset — soft HEAD@{1}

#Undo last commit, preserving local changes

git reset — soft HEAD~1

#Undo last commit, without preserving local changes

git reset — hard HEAD~1

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.