git checkout带注释的标记行为

时间:2018-05-13 16:03:57

标签: git

在对标签进行重命名时,我开始知道anotated标签是对象本身具有自己的SHA1 id。 HERE

我也知道git checkout如何解析他们的引用。 HERE

  

如果$ GIT_DIR /存在,那就是你的意思(这通常是   仅适用于HEAD,FETCH_HEAD,ORIG_HEAD,MERGE_HEAD和   CHERRY_PICK_HEAD);

     

否则,refs /如果存在;

     

否则,refs / tags /如果存在;

     

否则,refs / heads /如果存在;

     

否则,refs / remotes /如果存在;

     

否则,refs / remotes // HEAD如果存在。

现在我的问题是,当我执行git checkout some_annotated_tag_name甚至git checkout SHA1_ID_OF_ANNOTATED_TAG时,它会将我的HEAD切换到注释标记指向的提交,而不是注释标记的对象。

这背后的原因是什么?如果我提到一些SHA1 ID,它应该带我去SHA1 Id吗?

编辑:我们说我带注释的标签名称为annot。它的SHA1是216a2ee6ef4276566081c6dc1ee853bfd1798829,它指向的提交的SHA1是a8b21d7a46903e90d08338fd0311e2ead8d86eac

现在让我们看看我们得到了什么结果。

git checkout annot

输出:

Note: checking out 'annot'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at a8b21d7... 3rd

git checkout 216a2ee6ef4276566081c6dc1ee853bfd1798829

输出:

Note: checking out '216a2ee6ef4276566081c6dc1ee853bfd1798829'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>

HEAD is now at a8b21d7... 3rd

0 个答案:

没有答案