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

Re: previous references

From
DSDaniele Segato <daniele.bilug@gmail.com>
Date
Oct 5, 2009, 21:11 UTC
Message-ID
<1254777067.26111.105.camel@localhost>
In-Reply-To
<200910041127.29588.johan@herland.net>
Il giorno dom, 04/10/2009 alle 11.27 +0200, Johan Herland ha scritto:
Show 9 quoted lines
> On Sunday 04 October 2009, Octavian Râşniţă wrote:
> > Are the following commands specifying the same reference?
> > 
> > prompt> git log -1 HEAD^^^ ... log entry ...
> > prompt> git log -1 HEAD^~2 ... log entry ...
> > prompt> git log -1 HEAD~1^^ ... log entry ...
> > prompt> git log -1 HEAD~3 ... log entry ...
> 
> Yes

the ~ is used to select the first parent of a commit and their grand-parents

HEAD~ means the parent of the current head HEAD~2 means the grand-parent HEAD~3 the grand-grand-parent..

the ^ is used to select a direct parent of a commit HEAD^ is the same as HEAD~ HEAD^^ is the same as HEAD~2 (parent of the parent) HEAD^2 is NOT the same of HEAD~2, it means the "second parent" of HEAD: this make sense only if HEAD has at least two parents (because it is a merge commit) if it hasn't you'll get:

fatal: ambiguous argument 'HEAD^2': unknown revision or path not in the working tree. Use '--' to separate paths from revisions

you can read the same here: http://progit.org/book/ch6-1.html

regards, Daniele

Previous: Johan HerlandNext: Sverre Rabbelier
Message 3 of 4 in “previous references”
  1. Octavian RâşniţăOct 4, 2009
  2. Johan HerlandOct 4, 2009
  3. Daniele SegatoOct 5, 2009
  4. Sverre RabbelierOct 5, 2009

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.