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

Re: [ANNOUNCE] GIT 1.6.2-rc1

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 16, 2009, 21:42 UTC
Message-ID
<7vvdradpng.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<76718490902160902q50c0d730j4f18664455626b93@mail.gmail.com>
Jay Soffian <jaysoffian@gmail.com> writes:
Show 7 quoted lines
>  master> git checkout next
>    next> git branch --track mybranch @{-1}
>
> Creates "mybranch" from master, *not from next*, correct?
>
> Also, the "--track" option is an unnecessary distraction to the
> example, isn't it?

When a new branch is created in "git branch --track A B" form, B is used in two ways.

 * Obviously, the new branch A initially points at the same commit as
   commit B.  For this, B does not have to be the name of a branch.  It
   only has to be a commit-ish.
 * With --track, the new branch A is marked as a fork of the branch B, but
   obviously for this additional feature to kick in, you cannot give an
   arbitrary commit-ish as B.  It has to be the name of a branch you are
   forking from.

If B were spelled @{1}, the latter does not happen, as @{1} is a way to say "The _commit_ my current branch was pointing at before it point the current commit". On the other hand, @{-1} is a way to say "The _branch_ I switched from my last 'git checkout' command", and the command ought to behave the same as if you gave it a branch name, and --track takes place.

So having --track explicitly in the example is a good way to clarify the point that @{-N} notation is a way to spell _a branch name_, and it is not merely another commit-ish.

Previous: Jay Soffian
Message 4 of 4 in “[ANNOUNCE] GIT 1.6.2-rc1”
  1. Junio C HamanoFeb 16, 2009
  2. Matt KraaiFeb 16, 2009
  3. Jay SoffianFeb 16, 2009
  4. Junio C HamanoFeb 16, 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.