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

Re: Branch Management questions

From
Jeff King <peff@peff.net>
Date
Oct 15, 2020, 19:57 UTC
Message-ID
<20201015195754.GD1490964@coredump.intra.peff.net>
In-Reply-To
<595540a9-0000-8dcd-c555-3168d1b2d066@gmail.com>
On Thu, Oct 15, 2020 at 05:51:39AM -0400, Leam Hall wrote:
Show 8 quoted lines
> 1. Two developers.
>   Dev A is working on Branch A, off a release_candidate branch.
>   Dev B is working on Branch B, off the same release_candidate branch.
>   Branches usually run 1-4 weeks.
>   Dev A does some work that would help Branch B.
>   How does Dev A get the Branch B work that is needed, in a
>     way that does not confuse the merge process at the end
>     of the release cycle?
If Dev A is OK getting _all_ of branch B, the best thing is to simply:
  git checkout branch-a
  git merge branch-b
That goes from:
  old -- a1 -- a2 -- a3   <-- branch-A
     \
      b1 -- b2 -- b3       <-- branch-B
to: 
  old -- a1 -- a2 -- a3 -- M  <-- branch-A
     \                    /
      b1 -- b2 -- b3 ----+    <-- branch-B

and then later when they merge again (either separately, or into release_candidate), Git knows that "M" is the merge-base instead of "old":

  old -- a1 -- a2 -- a3 -- M -- a4 -- a5 -- a6 <-- branch-A
     \                    /
      b1 -- b2 -- b3 ----+-- b4 -- b5 -- b6    <-- branch-B

If you need just parts of the work on b, then you'd probably have to cherry-pick them. They should usually merge together cleanly eventually, but if you further modify them (or touch nearby areas), that may result in a conflict on merge into release_candidate.

Show 6 quoted lines
> 2. One developer.
>   Working on Branch P, realizes that a new functionality X is
>     needed.
>   X isn't specific to Branch P, but critical to it.
>   What is the best way to deal with X, knowing that further work
>     on X will need to be done?

Create a new branch X for the shared topic, and base it not on P but on whatever the fork point of P is (i.e., your release_candidate or whatever). Then do some work on X, and merge X into P as needed. Likewise for any other branch that builds on X.

If you've already built part of X on top of P, then you could cherry-pick those parts onto the new branch X, and then either:

  - rebase P on top of X (which will drop the redundant bits)
  - merge X into P. You may have to resolve conflicts around the
    redundant parts, and you'll have some redundant commits left in the
    history (but the new merge will become the base for further merges
    between the branches)
-Peff
Previous: Konstantin Tokarev
Message 5 of 5 in “Branch Management questions”
  1. Leam HallOct 15, 2020
  2. Konstantin TokarevOct 15, 2020
  3. Leam HallOct 15, 2020
  4. Konstantin TokarevOct 15, 2020
  5. Jeff KingOct 15, 2020

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.