Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
199 views
in Technique[技术] by (71.8m points)

git - Git中的HEAD是什么?(What is HEAD in Git?)

You see the Git documentation saying things like

(您会看到Git文档说出类似)

The branch must be fully merged in HEAD.

(分支必须在HEAD中完全合并。)

But what is Git HEAD exactly?

(但是到底什么是Git HEAD ?)

  ask by bobobobo translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can think of the HEAD as the "current branch".

(您可以将HEAD视为“当前分支”。)

When you switch branches with git checkout , the HEAD revision changes to point to the tip of the new branch.

(当您使用git checkout切换分支时,HEAD版本将更改为指向新分支的尖端。)

You can see what HEAD points to by doing:

(您可以通过执行以下操作查看HEAD指向的内容:)

cat .git/HEAD

In my case, the output is:

(就我而言,输出为:)

$ cat .git/HEAD
ref: refs/heads/master

It is possible for HEAD to refer to a specific revision that is not associated with a branch name.

(HEAD可能引用与分支名称不相关的特定修订版。)

This situation is called a detached HEAD .

(这种情况称为“ 分离的HEAD” 。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...