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

Re: git switch error message tweak

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 17, 2020, 20:30 UTC
Message-ID
<xmqq8sgltoyb.fsf@gitster.c.googlers.com>
In-Reply-To
<BL0PR11MB34603334FD8AF4B662A74C3A9D9D0@BL0PR11MB3460.namprd11.prod.outlook.com>
Ed Avis <ed.avis@qmaw.com> writes:
Show 11 quoted lines
> To help those migrating from 'git checkout' to the newer 'git switch'
> and 'git restore', this error message could be improved:
>
> % git switch baa022666d26a5d40e86c0b6349eb7435033e80a
> fatal: a branch is expected, got commit 'baa022666d26a5d40e86c0b6349eb7435033e80a'
>
> It could print additionally
>
> To switch to this commit in 'detached HEAD' mode, use --detach.
>
> as long as it was indeed a commit that was given.
Excellent.
> I note also that while git checkout prints a spiel about "You are in
> 'detached HEAD' state", git switch --detach does not. Was this
> deliberate, on the assumption that if you pass --detach you know what
> you are doing?

I'd say you are correct---one who passes "--detach" knows enough to want to be in the detached HEAD state and knows enough that the state is nothing to be worried about.

Previous: Ed Avis
Message 2 of 2 in “git switch error message tweak”
  1. Ed AvisJun 16, 2020
  2. Junio C HamanoJun 17, 2020

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.