我創建了一個對象標籤貓文件標記對象報告致命
git tag -a tag_1 -m "test tag"
但下面的命令報告一個致命的錯誤:
git cat-file -t tag_1^{tag}
fatal: Not a valid object name tag_1^{tag}
但是,下面的一個正常工作:
git cat-file -t master^{commit}
commit
它爲什麼報告致命?
我創建了一個對象標籤貓文件標記對象報告致命
git tag -a tag_1 -m "test tag"
但下面的命令報告一個致命的錯誤:
git cat-file -t tag_1^{tag}
fatal: Not a valid object name tag_1^{tag}
但是,下面的一個正常工作:
git cat-file -t master^{commit}
commit
它爲什麼報告致命?
用於指定git cat-file
中對象的語法是gitrevisions中指定的語法。
<object>
The name of the object to show.
For a more complete list of ways to spell object names, see the "SPECIFYING REVISIONS
" section in gitrevisions(7).
而且它適用於<rev>
。
<rev>^{<type>}, e.g. v0.99.8^{commit}
A suffix
^
followed by an object type name enclosed in brace pair means the object could be a tag, and dereference the tag recursively until an object of that type is found or the object cannot be dereferenced anymore (in which case, barf).
<rev>^0
is a short-hand for<rev>^{commit}
.
在這種情況下,我不知道它可以解引用tag_1
「直到該類型的對象被發現」(因爲它已經是一個標籤)。
@Vince「''包含樹blob提交標記」。同意。 「'v0.99.8^{commit}'」表示取消引用標籤'v0.99.8'直到找到提交。但就你而言,你試圖解引用標籤,直到找到標籤。我不確定它可以(應該)工作。 –
VonC
原始人說:「遞歸引用標籤,直到找到該類型的對象」。注意「那種類型」的關鍵詞。所以我認爲如果目標類型是標籤,它應該返回自我。也許這是設計(作爲例外)或將來修復的。 :) – Vince