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

Re: Orphan branch not well-defined?

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 22, 2023, 01:08 UTC
Message-ID
<xmqqil5uegrg.fsf@gitster.g>
In-Reply-To
<FE2AD666-88DE-4F70-8D6D-3A426689EB41@me.com>
Craig H Maynard <chmaynard@me.com> writes:
Show 5 quoted lines
> Recently I tried creating an orphan branch in an existing repo using git-checkout and git-switch. 
>
> Both commands have an --orphan option.
>
> The results were different:

This is one of the very much deliberate differences between "switch" and "checkout" (there are others).

The "switch" command was introduced as an experiment to figure out a better UI choices for one half of "checkout", which deals with checking out a branch to a working tree (the other half being "restore", which is about checking out files out of a tree-ish). The initial round of "switch" proposed to go with the identical semantics as "checkout" for the "--orphan" option [*1*], but during review discussion, a concensus was reached that a better behaviour for creating an entirely new history may be to start from void [*2*], and that is what is in the experimental command you see.

[Reference]
*1* https://lore.kernel.org/git/20190130094831.10420-9-pclouds@gmail.com/
*2* https://lore.kernel.org/git/CABPp-BF3_p3+fmQcWYEu2z3J4FfPmDmiMyFiBRXyz8TxKLL7jA@mail.gmail.com/
Previous: Craig H MaynardNext: Chris Torek
Message 2 of 7 in “Orphan branch not well-defined?”
  1. Craig H MaynardNov 22, 2023
  2. Junio C HamanoNov 22, 2023
  3. Chris TorekNov 22, 2023
  4. Junio C HamanoNov 24, 2023
  5. Junio C HamanoNov 24, 2023
  6. Eric SunshineNov 24, 2023
  7. Junio C HamanoNov 24, 2023

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.