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

Re: New orphan worktree?

From
SMStefan Monnier <monnier@iro.umontreal.ca>
Date
Jan 6, 2021, 22:56 UTC
Message-ID
<jwvk0spr8ta.fsf-monnier+Inbox@gnu.org>
In-Reply-To
<CAEE75_1o+A13+8SBeF9S0SN0ZaYhgK3D1bhbfWNWZWsj9jOXrw@mail.gmail.com>
Show 8 quoted lines
>> not a good example to support the use of the "--orphan" option.
> I agree with that part, slathering infrastructure and abstractions on
> oneliners (okay, twoliners) is suspect in my book. worktree add,
> symoblic ref (really, no need to get lowlevel there, checkout --orphan
> does it) done. Tag an empty commit and the sequence gets closer
> to a legit oneliner
>
>     git worktree add foo empty; git -C foo checkout --orphan newbranch

FWIW, I'd be quite happy to have an ad-hoc revision which represents "the (currently non-existing) ancestor shared by all branches". Assuming we'd call it "ORPHAN" (other names that come to mind would be "ROOT", "GOD", "∅", "BIGBANG", ...), then

    git checkout --orphan newbranch
would become
    git checkout -b newbranch ORPHAN
and then I'd also be able to say
    got worktree add -b newbranch foo ORPHAN

I've had occasional use for such a pseudo-revision in other circumstances as well and I think I'd find it easier to remember how to use this then the `--orphan` option.

        Stefan
Previous: Jim HillNext: Stefan Monnier
Message 21 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.