HEAD总是指的是“主人”指的是什么(在这种情况下)?(Does HEAD always refer to what “master” refers to (in this context)?)

假设一个在分支“master”上,并且HEAD位于分支的顶端(例如,在提交C )。 假设然后执行git reset --hard HEAD^3返回提交A 然后HEAD现在指的是A

问题: “master”是否也指A ,还是指向C ? 换句话说:在这种情况下,HEAD 总是引用分支“master”的作用(即,假设我们的存储库只有一个名为“master”的分支)?

Suppose one is on branch "master" and that HEAD is at the tip of the branch (say, on commit C). Suppose one then executes git reset --hard HEAD^3 back to commit A. Then HEAD now refers to A.

Question: Does "master" also refer to A, or is it still pointing at C? Put differently: in this context, does HEAD always refer to what the branch "master" does (i.e., assuming that our repository has only one branch named "master")?

最满意答案

让我们检查一下,目前的分支是:

$ git branch * master

回购的当前状态:

$ git log --oneline e585b43 C 4bbf8be B 6ae7d39 A fb4949b Initial commit

让我们改变一下吧:

$ git reset --hard HEAD~3 HEAD is now at fb4949b Initial commit

让我们来看看HEAD指出的位置:

$ git log HEAD --oneline fb4949b Initial commit

让我们检查一下主要点:

$ git log master --oneline fb4949b Initial commit

正如你可以看到HEAD和master指向同一个提交

Let's check it, current branch is:

$ git branch * master

current state of the repo:

$ git log --oneline e585b43 C 4bbf8be B 6ae7d39 A fb4949b Initial commit

Let's rebase it:

$ git reset --hard HEAD~3 HEAD is now at fb4949b Initial commit

Let's check where HEAD points:

$ git log HEAD --oneline fb4949b Initial commit

Let's check where master points:

$ git log master --oneline fb4949b Initial commit

As you can see HEAD and master point at the same commit

HEAD总是指的是“主人”指的是什么(在这种情况下)?(Does HEAD always refer to what “master” refers to (in this context)?)

假设一个在分支“master”上,并且HEAD位于分支的顶端(例如,在提交C )。 假设然后执行git reset --hard HEAD^3返回提交A 然后HEAD现在指的是A

问题: “master”是否也指A ,还是指向C ? 换句话说:在这种情况下,HEAD 总是引用分支“master”的作用(即,假设我们的存储库只有一个名为“master”的分支)?

Suppose one is on branch "master" and that HEAD is at the tip of the branch (say, on commit C). Suppose one then executes git reset --hard HEAD^3 back to commit A. Then HEAD now refers to A.

Question: Does "master" also refer to A, or is it still pointing at C? Put differently: in this context, does HEAD always refer to what the branch "master" does (i.e., assuming that our repository has only one branch named "master")?

最满意答案

让我们检查一下,目前的分支是:

$ git branch * master

回购的当前状态:

$ git log --oneline e585b43 C 4bbf8be B 6ae7d39 A fb4949b Initial commit

让我们改变一下吧:

$ git reset --hard HEAD~3 HEAD is now at fb4949b Initial commit

让我们来看看HEAD指出的位置:

$ git log HEAD --oneline fb4949b Initial commit

让我们检查一下主要点:

$ git log master --oneline fb4949b Initial commit

正如你可以看到HEAD和master指向同一个提交

Let's check it, current branch is:

$ git branch * master

current state of the repo:

$ git log --oneline e585b43 C 4bbf8be B 6ae7d39 A fb4949b Initial commit

Let's rebase it:

$ git reset --hard HEAD~3 HEAD is now at fb4949b Initial commit

Let's check where HEAD points:

$ git log HEAD --oneline fb4949b Initial commit

Let's check where master points:

$ git log master --oneline fb4949b Initial commit

As you can see HEAD and master point at the same commit