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

Re: git checkout -t -B

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Aug 27, 2012, 12:20 UTC
Message-ID
<CACsJy8A=GooUesw0hJ7AiDO7M3v1Ybbox8+rwWJfn6urJQUUFw@mail.gmail.com>
In-Reply-To
<7v8vd1v6q2.fsf@alter.siamese.dyndns.org>
On Mon, Aug 27, 2012 at 1:38 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 14 quoted lines
> 乙酸鋰 <ch3cooli@gmail.com> writes:
>
>> git checkout -t -B origin/abcde
>> works
>>
>> but
>> git checkout -B -t origin/abcde
>> does not.
>>
>> Could you document the order of parameters or fix the behaviour?
>
> It is crystal clear that -b/-B/--orphan must be followed by the name
> of the branch you are creating from the SYNOPSIS section of the
> documentation.
Yet it's not very clear from the error message:
    fatal: git checkout: updating paths is incompatible with switching branches.
    Did you intend to checkout 'origin/abcde' which can not be
resolved as commit?

I wonder if we should reject -t as a value of -[Bb] by adding new parseopt flag to reject values starting with '-'. In this case, branch names can't start with '-'. There may be cases where we accept option value starting with '-', but I suspect the other way is dominant.

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 8 in “git checkout -t -B”
  1. 乙酸鋰Aug 26, 2012
  2. Junio C HamanoAug 26, 2012
  3. Nguyen Thai Ngoc DuyAug 27, 2012
  4. Junio C HamanoAug 27, 2012
  5. Philip OakleyAug 27, 2012
  6. Junio C HamanoAug 27, 2012
  7. Philip OakleyAug 28, 2012
  8. doc: "git checkout -b/-B/--orphan" always takes a branch nameJunio C Hamano, Aug 26, 2012

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.