What is the exact use of DETACHED HEAD state in Git?
The &quot;normal&quot; way of working with GIT is by checking out branches. HEAD is a &quot;pointer&quot; to the latest commit in that branch, and GIT will allow you to commit new changes after that pointer.
However, as you figured out, it is possible to check out a specific commit hash, if you want to. In this situation, if you make changes and try to commit them, you will be unable to do so, since you are not at HEAD, and GIT will not allow you to commit your changes.
Most of the time, detached HEAD (checking out an older commit) is used if you want to test how your project ran at a certain point in time.
If you need to make changes to the code or need to build it using Jenkins MultiBranch Pipelines, for example, it is also possible to create a new branch from that specific commit by running:
git branch my_new_fancy_branch 7y8u33ii
or
git checkout -b my_new_fancy_branch 7y8u33ii
... where 7y8u33ii is the hash you provided in the question. For this new branch, 7y8u33ii will be HEAD, so you will be able to commit new changes. If you need to get your code into the branch from which you created this new branch from, you will need to do a merge, but this is another discussion altogether.