In git
the concept head
is not general. It is so that every branch
has, so to say, its own head
pointing normally to the last commit in the timeline for that branch.
On the other hand HEAD
exists just once per repository and points to the head of the current branch, that is the current head.
So HEAD
is always used within the context of your branch and not of the whole repository. That's the reason why git reset --soft HEAD^
moves you one commit back and not to the previous position
If you take a look at the files within the .git
folder you can clearly appreciate this concept:
.git/HEAD
This file contains a reference to the position where the HEAD (uppercase) of the repo is
.git/refs/heads
This folder contains one file for each branch with the reference to its head (lowercase). The previous file will usually point to one of these unless there is a detached HEAD