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

Re: Is current HEAD pointing at a given revision ?

From
Jakub Narebski <jnareb@gmail.com>
Date
Jun 14, 2011, 09:00 UTC
Message-ID
<m3mxhkvlcw.fsf@localhost.localdomain>
In-Reply-To
<BANLkTikFTHc4Qiu1YLxXgPhweNnVqMO11Q@mail.gmail.com>
Francis Moreau <francis.moro@gmail.com> writes:
> I have a given revision (tag, sha1 ...) and I'd like to know if that
> revisions corresponds to what the current HEAD is pointing at.
> 
> Could anybody give me some advices for achieving this ?

If you want to know if given revision (or ref) points at the same thing as HEAD, you can use

  [ "$(git rev-parse HEAD)" = "$(git rev-parse $ref^{commit})" ]

or something like that. The '^{commit}' is here in case $ref points only indirectly to commit, via a tag object.

If you want to kow if current HEAD is tagged, you can use instead
  git describe --exact-match HEAD
-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Francis MoreauNext: Francis Moreau
Message 2 of 5 in “Is current HEAD pointing at a given revision ?”
  1. Francis MoreauJun 14, 2011
  2. Jakub NarebskiJun 14, 2011
  3. Francis MoreauJun 14, 2011
  4. Jakub NarebskiJun 14, 2011
  5. Francis MoreauJun 14, 2011

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.