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, 23:08 UTC
Message-ID
<7vd3ejq74z.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CABURp0rjBdx+=_8R5g16fNKWis3=GgJw9SQ9D53H6xu_-Tq3Uw@mail.gmail.com>
Phil Hord <phil.hord@gmail.com> writes:
Show 6 quoted lines
>> I am saying that "separate history" has no place in git workflow, if these
>> multiple roots _originate_ in the same single repository with a working
>> tree.
>
> No place in *your* workflow.  Oh, wait.  Except it has, and you use it
> in the git tree.  So, um...  I'm confused.
No, no place in anybody's workflow.

I do carry non source html/man branches in the same distribution point repository, but I did not create and I do not have these unrelated branches in my development repository. Possibility to run "git checkout html" in my development repository is just insane.

The branch switching semantics of Git is designed to work well when all the branches you check out in the working tree are somewhat related content-wise. You create a new file, or make modifications to an existing file, realize that the change wants to go to a branch different from the current one. You _can_ switch to the branch the change should belong to, because the contents in the working tree is defined to be not tied to any branch, but is floating on top of the current branch.

We often see new people who do not understand this (yet) wonder "I modified a file, switched to another branch, but the modification is still there. Why?" It is because the local changes in the working tree do not belong to a specific branch, and local changes could be committed to any branch.

What would happen if I were crazy enough to have the html branch in my development repository and checked it out? In addition to the previous build artifacts *.o files, new source files *.[ch] and documentation sources Documentation/*.txt will stay and will be mixed in the checkout of the html branch, where we all know there is no reason for them to be committed on.

A sane way to use Git is to have a separate repository to keep track of changes in the other unrelated material, and I have separate repositories with checkouts for html and man. Of course I do not edit them manually; these repositories are targets of "make install-doc" from the source repository.

They happen to be pushed into the same distribution point repository, but that is a mere historical artifact. It only started because at k.org I only had a write access to /pub/scm/git/git.git but not to /pub/scm/git/ directory itself; I may have used /pub/scm/git/html and /pub/scm/git/man repositories otherwise.

And cloners are advised to "tar-tree" these out and extract them to somewhere else, if they do not want to format the documentation themselves but still want to look at them. Of course, they could "checkout", but you would not edit these generated files in the working tree or commit to these branches. So in that sense, yes they could "checkout", but that is like saying they can run "rm -fr .git" too---they can do useful things and not so useful things just alike.

I suspect that people often see those html/man branches in the distribution point repository and get a wrong idea that having these unrelated histories somehow add their coolness factor. It doesn't.

Show 9 quoted lines
>> I have no trouble in a single repository with multiple roots if that is
>> done in a distribution point, which by definition does not need and
>> typically does not have any working tree. Options to "checkout/commit"
>> would not help as they need a working tree.
> ...
>> The way to do it is to work in multiple repositories, one for each of
>> these roots, and push into a single repository from them.
>
> That's one way to do it.

And I have been trying to teach why the other way is a wrong thing to do, but there is no point in teaching a better practice if the listener is not willing to learn. My time is better spent on other topics.

Previous: Michael WittenNext: Michael Witten
Message 54 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.