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

Re: New orphan worktree?

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 6, 2021, 21:29 UTC
Message-ID
<xmqq1rexrbz1.fsf@gitster.c.googlers.com>
In-Reply-To
<CABPp-BE1QXA0ohB9D-tqKpzDTok0BMsGQjotmcqMxfs9AL5noA@mail.gmail.com>
Elijah Newren <newren@gmail.com> writes:
Show 5 quoted lines
> Sidenote:
>
> Yeah, checkout --orphan is broken.  You should use switch --orphan,
> which doesn't require the extra 'git rm -rf .' step.  That bit is
> definitely cumbersome.
I doubt "broken" is an appropriate word.  

It only targets a different workflow that wanted to start an unrelated history with a known contents.

> Out of curiosity, why are you frequently creating orphan branches?
> Such an option would drop the number of commands you need to run from
> four down to two, but I'm surprised this would come up enough to
> matter enough to do much more than create a personal git alias for it.

Yes, a need to have multiple unrelated line of histories in a single repository may not be there, even though a desire to do so might exist. What is done with these unrelated histories that record unrelated contents [*1*]?

For example, the answer might turn out to be "our hosting provider charge by number of publishing repositories, so I keep only one repository there and push unrelated stuff into it, on different branches", and such a use case to work around external limitation can be more naturally solved by having separate repositories on the producing side, and pushing into different branches in that single publishing repository, which does not require any "--orphan" at all.

[Footnote]
*1* if the trees in these unrelated histories record related
    contents, the user wouldn't be doing "git rm -f ." in the first
    place and "checkout --orphan" would be more appropriate than
    "switch --orphan".
Previous: Junio C HamanoNext: Jim Hill
Message 17 of 22 in “New orphan worktree?”
  1. Stefan MonnierJan 6, 2021
  2. Jim HillJan 6, 2021
  3. Elijah NewrenJan 6, 2021
  4. Jim HillJan 6, 2021
  5. Elijah NewrenJan 6, 2021
  6. Eric SunshineJan 6, 2021
  7. Ævar Arnfjörð BjarmasonFeb 18, 2021
  8. Eric SunshineFeb 21, 2021
  9. Ævar Arnfjörð BjarmasonFeb 22, 2021
  10. Eric SunshineFeb 22, 2021
  11. Junio C HamanoFeb 22, 2021
  12. Eric SunshineFeb 23, 2021
  13. Ævar Arnfjörð BjarmasonFeb 23, 2021
  14. Eric SunshineFeb 23, 2021
  15. Ævar Arnfjörð BjarmasonFeb 23, 2021
  16. Junio C HamanoFeb 23, 2021
  17. Junio C HamanoJan 6, 2021
  18. Jim HillJan 6, 2021
  19. Junio C HamanoJan 6, 2021
  20. Jim HillJan 6, 2021
  21. Stefan MonnierJan 6, 2021
  22. Stefan MonnierJan 6, 2021

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.