我有一个https://github.com/carrierwaveuploader/carrierwave repo的分支,最近尝试检出特定的SHA,但是指向了不同的SHA。它表现得好像两个不同的SHA实际指向同一个位置,这应该不会发生!
这是复制/粘贴的bash输出:
$ git checkout 16bafdd41cb993f65919fcf12fc03ff6c9246a33
Note: checking out '16bafdd41cb993f65919fcf12fc03ff6c9246a33'.
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 396f538... Merge pull request #1160 from pjg/patch-1
$ git status
# Not currently on any branch.
nothing to commit, working directory clean
$ git log
commit 396f5384c67f8a17c153c15da0f1d06bc1f116e4
...
$ git checkout 396f5384c67f8a17c153c15da0f1d06bc1f116e4
HEAD is now at 396f538... Merge pull request #1160 from pjg/patch-1
$ git checkout 16bafdd41cb993f65919fcf12fc03ff6c9246a33
HEAD is now at 396f538... Merge pull request #1160 from pjg/patch-1
回答迈克尔安德森:
$ git cat-file -t 16baf
tag
$ git cat-file -t 396f5
commit
答案 0 :(得分:4)
你回答了你的问题。
您只能查看提交。由于标签是4个git对象之一(其他是blob,tree和commit),因此它们获得SHA。但他们仍然是提交的指针。而你只能查看提交。没有其他对象可以签出。
当您尝试签出标记或分支时,会检查这些提交的提交。