Another situation that causes a detached HEAD is checking out the remote branch. We already demonstrated that if you check out the SHA-1 commit hash, you will be in the detached HEAD state.
Then, we will demonstrate how to save or discard changes in a detached head so you can quickly recover from the situation. In this article, we will explore what the Git detached HEAD state is and some situations that cause it. Complex commands and a less intuitive user interface can sometimes lead to unwanted states, including a state called detached HEAD. However, learning Git is more complicated than learning SVN or CVS. It is fast, scalable, and has more commands and flexibility than older version control tools like Apache Subversion (SVN) and Concurrent Versions System (CVS). It makes collaboration easier by allowing branching to keep code for different features separate and seamlessly merging commits by various people. Git allows developers to maintain a history of changes, or commits, to their code and revert to previous commits in seconds if something goes wrong.
The introduction of Git as a source-code management system in 2005 fundamentally transformed the process of software development.