Home > Development Tools > git > What is the git detached head pointer?

What is the git detached head pointer?

WBOY
Release: 2022-06-24 10:49:50
Original
3045 people have browsed it

The git detached head pointer is a state where the HEAD pointer no longer points to the branch, but directly points to a commit; generally the HEAD pointer points to the branch, and the branch points to the commit, and the detached head pointer refers to The changes are not based on a certain branch. When we switch branches, the changes are likely to be lost. In this case, we need to create a new branch and bind the changes to the branch.

What is the git detached head pointer?

The operating environment of this article: Windows 10 system, Git version 2.30.0, Dell G3 computer.

What is the git detached head pointer

When Git is used, there is a state called the detached head pointer state, also called detached HEAD.

We can learn from previous updates that in Git the HEAD pointer points to the branch, and the branch points to the commit. The so-called detached head pointer state means that the HEAD pointer no longer points to the branch, but directly points to a commit.

What is the git detached head pointer?

Usually, we work on a certain branch, such as the master branch. At this time, the master pointer and the HEAD pointer are moving forward together. Every time a commit is made, these two pointers will move forward one step together. However, under certain circumstances (such as checking out a specific commit), the "binding" state of the master pointer and the HEAD pointer is broken and becomes the detacged HEAD state.

The detached head pointer refers to the change that is not based on a certain branch. When we switch branches, the change is likely to be lost. At this time we need to create a new branch and bind the change to the branch.

1. As shown in the picture below, I am currently in a normal state

What is the git detached head pointer?

#2. At this time, I switched to a commit and the detached head pointer state appeared.

What is the git detached head pointer?

3. Modify the file content in the detached head pointer state and submit

What is the git detached head pointer?

Recommended study: " Git tutorial

The above is the detailed content of What is the git detached head pointer?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
git
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template