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.