Git Detached HEAD
A detached HEAD means HEAD points straight to a commit, not to a branch. You get one when you check out a commit hash or a tag.
New commits you make are not on any branch, so switch back to a branch, or create one, before you go on.
Check out an older commit
git checkout HEAD~2
Note: switching to 'HEAD~2'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.
...
HEAD is now at 8874051 Changed heading to Hello W3Schools
git status
HEAD detached at 8874051
nothing to commit, working tree clean
Keep your work on a new branch
Create a branch where you are now:
git switch -c fix-old-bug
Switched to a new branch 'fix-old-bug'