I understand that the git reset
command moves a branch backwards in the history (*), and that the branch it moves is the one that HEAD
is pointing to.
So I got curious and I tried to call it in a detached HEAD state
to see what would happen. I was expecting error but git did something, and I'm just unable to figure out what it did.
Did Git acted like HEAD
was still pointing to where it was before I checked out and went into the detached HEAD state
?
[ Edit 1 ] I actually figured it out. It does exactly the same as when one is not in a detached head state, except that it doesnt move any branch backward. It's only the
[ Edit 2(*) ] The git reset
actually only moves a branch backward in history when specifying an older commit. When doing git reset HEAD
, it leaves the branch where it is (see comments below).
git reset
makes the current branch and HEAD move to a specific commit. If it's a detached HEAD, it makes only HEAD move.