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

Re: What are branches?

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 21, 2009, 00:53 UTC
Message-ID
<7vd4b6ddzn.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<87r5znashf.fsf@gmail.com>
Marius Vollmer <marius.vollmer@gmail.com> writes:
Show 14 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> If we made it easy for Dscho to create the merge M to record my tree as
>> the first parent, [...]
>
> But it _is_ easy for Dscho to do that, isn't it?  He just needs to
> remember to do the merge the other way around, checking out your branch
> and merging his into it.
>
> This doesn't change much, of course, since we still can't follow a
> branch backwards in time reliably.  Would it make sense to record
> additional information in a merge commit, such as the branch name for
> each parent?  Then tools could automatically draw the history of the
> current branch as a straight line, say.

We already have record of that, but I do not think using it is necessarily healthy.

There are certainly cases where the relationship between the maintainer and a contributor makes one branch "the primary" in the sense that it is the integration ground for everything under the sun, as opposed to the other one that is "the side branch that was merged" in the sense that it brought in a more narrowly focused set of patches. If you examine the merge commit M Dscho makes in the example in my previous message, it shows that one of the parents was committed by me and the other was committed by Dscho. By following my commits over Dscho's, you will identify which one of the parents of a merge is the mainline. You would perhaps instead of "git log --first-parent" use "git log --mainline=gitster" or something like that.

The point is that a convention to follow my commits over Dscho's commits is just as valid as a convention to follow the first parent. It is purely a social convention.

A more problematic is that in a distributed environment, there doesn't necessarily such a "mainline vs side branch" relationship exist, and it is not healthy to try to introduce such a concept like "mainline" when there is no such thing.

Perhaps Alice and Bob forked at the same point, agreeing between themselves that Alice works on the code updates while Bob updates the documentation as a team of two to produce a new feature. Before they collectively conclude their work and send a pull request to the project management, they will merge their branches to produce the end result that is pullable. From the overall project's point of view, the merge to get their work into the mainline will be "the mainline merges one side branch for the feature", but what about the merges between Alice and Bob while they work together? There is no "this is the mainline and this is a side branch" relationship between what they do.

Previous: Marius VollmerNext: Dmitry Potapov
Message 13 of 28 in “What are branches?”
  1. Johannes SchindelinApr 19, 2009
  2. Michael WittenApr 19, 2009
  3. Tuncer AyazApr 19, 2009
  4. Johannes SchindelinApr 19, 2009
  5. Tuncer AyazApr 19, 2009
  6. Dmitry PotapovApr 20, 2009
  7. Michael J GruberApr 20, 2009
  8. Dmitry PotapovApr 20, 2009
  9. Michael J GruberApr 20, 2009
  10. Dmitry PotapovApr 20, 2009
  11. Junio C HamanoApr 20, 2009
  12. Marius VollmerApr 20, 2009
  13. Junio C HamanoApr 21, 2009
  14. Dmitry PotapovApr 21, 2009
  15. Johannes SchindelinApr 20, 2009
  16. Björn SteinbrinkApr 20, 2009
  17. Jakub NarebskiApr 20, 2009
  18. Björn SteinbrinkApr 20, 2009
  19. Jakub NarebskiApr 24, 2009
  20. Björn SteinbrinkApr 24, 2009
  21. Dmitry PotapovApr 20, 2009
  22. Johannes SchindelinApr 20, 2009
  23. Michał KiedrowiczApr 20, 2009
  24. Dmitry PotapovApr 20, 2009
  25. Björn SteinbrinkApr 20, 2009
  26. Brian GernhardtApr 20, 2009
  27. Felipe ContrerasApr 25, 2009
  28. Michael J GruberApr 20, 2009

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.