![]() ![]() Instead, it’s pointing to a specific commit. To reiterate, it means that the HEAD of your project is not pointing to a branch anymore. So what is a detached HEAD? According to Tower’s blog post: “When a specific commit is checked out instead of a branch – is what’s called a “detached HEAD.” Notice how both master branch and HEAD point to the same commit. And when you run a checkout command with a branch name, Git checks out the latest commit the branch points to.įollowing that logic, when HEAD points to a branch, it points to the latest commit under that branch. When you push to a branch, that label now points to the new commit. Simply put branches are labels for commits. But let’s try to come up with a simple definition. Git branchĪ lot of people have a general idea of what branch is. ![]() It also defines the current state of your project. The next question then is what is HEAD? HEAD is a pointer to your current working commit. Notice how each commits points to the previous one, except for the first commit. Here’s a diagram to illustrate this point: Each commit points to a previous commit as its parent. Commits are connected through the parent-child relationship. Git is a system made of objects and pointers. Don’t worry we’ll only cover enough to understand the root cause of the state. Basics of Gitįirst, let’s skim over how Git works. If you would like to know more about the reasoning behind the state, then read along. If you’re here for the solution, feel free to skip to the “How to fix” section. But let me put your worries at ease – the detached HEAD state is easily reversible and is a natural state of a project. I wish the creators of Git picked a less alarming one. I agree, the You are in 'detached' HEAD state message does sound scary. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |