Say I have a Git repo with three commits:
$ git log --oneline
62fa462 (HEAD, master) Third commit
76f2df9 Second commit
c05b82a First commit
Now I accidentally use checkout
to move HEAD
to the second commit:
$ git checkout 76f2df9
Previous HEAD position was 62fa462 Third commit
HEAD is now at 76f2df9 Second commit
I then want to restore the previous state so I use reset
:
$ git reset --hard 62fa462
HEAD is now at 62fa462 Third commit
That worked, and as can be seen in the log, HEAD
is again pointing to master
:
$ git log --oneline
62fa462 (HEAD, master) Third commit
76f2df9 Second commit
c05b82a First commit
However, when I check the status, I get:
$ git status
HEAD detached from 76f2df9
nothing to commit, working tree clean
I don't really get this, why is HEAD
still detached? In the log, it shows (HEAD, master)
so it should point to the master
branch, right? At least the log looks exactly like at the beginning when everything was fine.
What is going wrong here?