2017-08-04 88 views
8

所以,我以前沒有遇到過奇怪的事情。提交#的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日誌,我沒有看到fb4b6581任何地方,但我確實看到8a74070,這增加了我的困惑。

謝謝

回答

6

這意味着,與ID fb4b6581d36a522e092491d1dc5f49cb96ab7a3e的GIT中對象是標籤對象(一個annotated tag)。

你可以看到它:

$ git cat-file -t fb4b6581d36a522e092491d1dc5f49cb96ab7a3e 

,它將打印對象的類型,以及:

$ git cat-file -p fb4b6581d36a522e092491d1dc5f49cb96ab7a3e 

這將直接打印的原始標籤內容。 git show命令將首先顯示標記的內容,然後顯示標記指向的提交,這是另一個對象8a74070...

+0

我一直在使用'git show-ref#'來確定一個特定的標籤指向哪個提交#。事情是,這個工程對於所有標籤總是很好,除了這個。 假設我已經提交#s A,B和C,並且我有標籤tA - > A,tB - > B和tC - > C。如果我做'git show-ref A',我得到提交#對於A.對於B來說是一樣的。但是現在這種情況下,C,'git show-ref C'沒有顯示C的提交#。你碰巧知道爲什麼在這種情況下會有所不同? –

+0

啊!等等,繼續,我明白你在說什麼。我弄錯了帶有註釋標籤的標籤。非常感謝!更清楚。 –

相關問題