git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Trouble with cat-file on tags

From
Jeff King <peff@peff.net>
Date
Apr 1, 2016, 12:26 UTC
Message-ID
<20160401122631.GA12019@sigill.intra.peff.net>
In-Reply-To
<ndlgsc$ed7$1@ger.gmane.org>
On Fri, Apr 01, 2016 at 12:00:44PM +0200, Sebastian Schuberth wrote:
Show 5 quoted lines
> This means
> 
> $ git cat-file tag refs/tags/v0.1.2
> 
> displays the *contents* of the tag, not the tag itself.
Right. `cat-file` is about looking at object content.
Show 6 quoted lines
> Which leads me to
> the next question: For a given name of an annotated tag, how to get the hash
> of the tag object? The solution I found for now:
> 
> $ git show-ref --tags -- v0.1.2
> 92b67e2b0626519ef8cd4e9cacb2bdafba6d53f0 refs/tags/v0.1.2

Here you just want to resolve the ref, without looking at the object. The canonical way is:

  git rev-parse --verify v0.1.2

You can also use that to peel the tag to a commit, or a commit to a tree (e.g., with "v0.1.2^{commit}").

-Peff
Previous: Sebastian Schuberth
Message 4 of 4 in “Trouble with cat-file on tags”
  1. Sebastian SchuberthApr 1, 2016
  2. Sebastian SchuberthApr 1, 2016
  3. Sebastian SchuberthApr 1, 2016
  4. Jeff KingApr 1, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.