I have created a object tag
git tag -a tag_1 -m "test tag"
But the following command reports a fatal error:
git cat-file -t tag_1^{tag}
fatal: Not a valid object name tag_1^{tag}
However, the following one works fine:
git cat-file -t master^{commit}
commit
Why does it report fatal?
The syntax used to specify an object in git cat-file
is the one specified in 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).
And it applies to a <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}
.
In this case, I am not sure it can dereference tag_1
"until an object of that type is found" (since it is already a tag).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.