Git签出提交#会带我进行不同的提交#

时间:2017-08-04 16:55:20

标签: git

所以,我之前没遇到过的奇怪的东西。

$ git checkout fb4b6581d36a522e092491d1dc5f49cb96ab7a3e
Note: checking out 'fb4b6581d36a522e092491d1dc5f49cb96ab7a3e'.

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 8a74070...

基本上我的问题是,如果我检查了fb4b6581,为什么HEAD现在是8a74070?我的基本Git知识还不足以完全理解正在发生的事情。 如果我要在这个问题上添加更多信息,请告诉我,这是我所看到的问题的要点。

另外,请注意,如果我执行git log,我在任何地方都看不到fb4b6581,但我确实看到了8a74070,这增加了我的困惑。

谢谢

1 个答案:

答案 0 :(得分:6)

这意味着ID为{ "notNullA": "notNullA", "nullA": null, "objectA": { "notNullB": "notNullB", "nullB": null, "objectB": { "notNullC": "notNullC", "nullC": null }, "emptyObjectB": {}, "arrayB": [ "b" ], "emptyBrrayB": [] }, "emptyObjectA": {}, "arrayA": [ "a" ], "emptyArrayA": [] } 的Git对象是标记对象(带注释的标记)。

你可以看到它:

{
  "notNullA": "notNullA",
  "objectA": {
    "notNullB": "notNullB",
    "objectB": {
      "notNullC": "notNullC"
    },
    "arrayB": [
      "b"
    ]
  },
  "arrayA": [
    "a"
  ]
}

将打印对象的类型,并且:

fb4b6581d36a522e092491d1dc5f49cb96ab7a3e

将直接打印原始标签内容。 $ git cat-file -t fb4b6581d36a522e092491d1dc5f49cb96ab7a3e 命令将首先显示标记的内容,然后显示标记指向的提交,即另一个对象$ git cat-file -p fb4b6581d36a522e092491d1dc5f49cb96ab7a3e

相关问题