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

Re: In favor of "git commit --no-parent"

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 29, 2011, 18:11 UTC
Message-ID
<7vmxdnte0j.fsf@alter.siamese.dyndns.org>
In-Reply-To
<271cc2ed03774b4988bb61cb3e79750e-mfwitten@gmail.com>
Michael Witten <mfwitten@gmail.com> writes:
Show 11 quoted lines
> On Wed, 28 Sep 2011 13:34:22 -0700, Junio C Hamano wrote:
>
>> If you are bootstrapping a new open source project from the tip of a
>> proprietary tree, "checkout --orphan && edit to sanitize && commit" to
>> start your history afresh would be perfectly adequate for your PR people
>> to say "Now we are open".
>
> So, the two usages for a new root commit are:
>
>   * Separate History
>   * Hidden History
Show 7 quoted lines
> As it turns out, the command:
>
>   git checkout --orphan
>
> which should be renamed:
>
>   git checkout --no-parent
I doubt that "should be" is anywhere near consensus.
> is best for the "Separate History" case,...
Step back a bit. There are two independent issues:
 - When does it make sense to originate two independent histories in a
   single repository that has a working tree?
 - What is the best tool to originate a new independent history in a
   single repository that has a working tree?

As I said number of times already, be it done with "checkout --orphan" or "commit --no-parent", the "Separate History" use case is better done in a separate repository. There is *no* advantage to originate the two separate histories that do not share any resemblance of tree shape as branches in a single repository with a working tree; "git checkout $branch" between the two would actively work against you.

You are of course free to push from these separate repositories that have disjoint roots of their own into a single distribution repository for people to fetch from, if you want Separate Histories in a distribution point.

That leaves "Hidden History" the only useful use case. IOW, the answer to the first question above is not "Separate or Hidden History", but is "Hidden History and nothing else".

And a half of the the answer to the second question is "checkout --orphan" (and the other half would be "filter-branch"). "checkout --orphan" does have major safety advantage than introducing "commit --no-parent", as Peff pointed out earlier (to which I agreed).

Previous: Philip OakleyNext: Michael Witten
Message 20 of 57 in “Can a git changeset be created with no parent”
  1. vra5107Sep 25, 2011
  2. Andreas EricssonSep 25, 2011
  3. Carlos Martín NietoSep 25, 2011
  4. Junio C HamanoSep 26, 2011
  5. Carlos Martín NietoSep 26, 2011
  6. Docs: git checkout --orphan: `root commit' and `branch head'Michael Witten, Sep 27, 2011
  7. Matthieu MoySep 27, 2011
  8. Docs: git checkout --orphan: `root commit' and `branch head'Michael Witten, Sep 27, 2011
  9. Matthieu MoySep 27, 2011
  10. Michael WittenSep 27, 2011
  11. Matthieu MoySep 27, 2011
  12. Michael WittenSep 27, 2011
  13. Philip OakleySep 27, 2011
  14. Docs: git checkout --orphan: `root commit' and `branch head'Michael Witten, Sep 28, 2011
  15. Junio C HamanoSep 28, 2011
  16. Michael WittenSep 29, 2011
  17. Docs: git checkout --orphan: Copyedit, and s/root commit/orphan branch/Michael Witten, Sep 29, 2011
  18. Michael WittenSep 29, 2011
  19. Philip OakleySep 29, 2011
  20. Junio C HamanoSep 29, 2011
  21. Michael WittenSep 29, 2011
  22. Documentation/git-checkout.txt: Explain --orphan without introducing an undefined "orphan branch"Junio C Hamano, Sep 29, 2011
  23. Michael WittenSep 29, 2011
  24. Phil HordSep 29, 2011
  25. Michael WittenSep 29, 2011
  26. Phil HordSep 29, 2011
  27. Michael WittenSep 29, 2011
  28. Michael J GruberSep 27, 2011
  29. Michael WittenSep 27, 2011
  30. Junio C HamanoSep 27, 2011
  31. Michael WittenSep 27, 2011
  32. Eric RaibleSep 27, 2011
  33. Philip OakleySep 27, 2011
  34. Jeff KingSep 27, 2011
  35. Michael WittenSep 27, 2011
  36. Jeff KingSep 27, 2011
  37. Michael WittenSep 27, 2011
  38. Junio C HamanoSep 28, 2011
  39. Michael WittenSep 28, 2011
  40. Matthieu MoySep 28, 2011
  41. Michael WittenSep 28, 2011
  42. Matthieu MoySep 28, 2011
  43. Michael WittenSep 28, 2011
  44. Matthieu MoySep 28, 2011
  45. Michael WittenSep 28, 2011
  46. Junio C HamanoSep 28, 2011
  47. Jay SoffianSep 28, 2011
  48. Michael WittenSep 28, 2011
  49. Michael J GruberSep 28, 2011
  50. Junio C HamanoSep 29, 2011
  51. Phil HordSep 29, 2011
  52. Michael WittenSep 29, 2011
  53. Michael WittenSep 29, 2011
  54. Junio C HamanoSep 29, 2011
  55. Michael WittenSep 30, 2011
  56. Junio C HamanoSep 30, 2011
  57. Michael WittenSep 29, 2011

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.