Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Mike Jarmy <mjarmy@gmail.com>
Cc: Eugene Sajine <euguess@gmail.com>, git@vger.kernel.org
Subject: Re: Commiting changes onto more than one branch
Date: Wed, 25 Nov 2009 10:58:05 -0800	[thread overview]
Message-ID: <7vaayazb2a.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <6b4a562b0911250847x59116687iba1d1640ca6c3887@mail.gmail.com> (Mike Jarmy's message of "Wed\, 25 Nov 2009 11\:47\:54 -0500")

Mike Jarmy <mjarmy@gmail.com> writes:

> I guess I didn't explain it too well, I made it sound like v3, v4 and
> v5 were still more-or-less the same.  What I'm thinking about here is
> a case where we have switched to git a while back, and then done a lot
> of work on the various different branches, so that v3, v4 and v5 have
> diverged very far from each other.  In that case, we would never want
> to merge them together.

I take it to mean that even though v[345] have diverged, the area that the
particular change you have in mind has to touch haven't changed since they
forked.  Otherwise you wouldn't be able to apply the same change to all of
them in the same form and instead would be making the logically same
change in physically different ways per branch, and you won't be asking
this question.

        o--o--o--o--o--o--o--o v4
       /
    --o--x--x--x--x--x--x--x v3

If you implemented your change at the tip of v3 branch and merge the
result to v4, you will pull _all_ of 'x' into v4 that may not be desirable
if the branches diverged a lot, of course.  

        o--o--o--o--o--o--o--o-------M v4
       /                            /
    --o--x--x--x--x--x--x--x       /
                            \     /
                             Y---Y your change(s) == v3

But nobody tells you to do this.

Instead, you can fork such a topic from the latest common.

        o--o--o--o--o--o--o--o v4
       /
    --o--x--x--x--x--x--x--x v3
       \
        Y---Y
            your change(s)

and merging this to v3 and v4 will have the desired effect.

        o--o--o--o--o--o--o--o---------M v4
       /                              /
    --o--x--x--x--x--x--x--x---M v3  /
       \                      /     /
        Y---Y----------------.-----.
            your change(s)

The merges will incorporate this particular change alone without dragging
anything else.  When you merge it to v4, none of the unrelated 'x' will be
merged into it.

In general you shouldn't fork a topic from the _tip_ of the oldest branch,
if the branches are not meant to be merged as a whole.

Of course, if this becomes cumbersome, you would adopt a better branch
management to keep the numbers of 'x' that shouldn't be in later branches
to the minimum.

  parent reply	other threads:[~2009-11-25 18:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-25 16:31 Commiting changes onto more than one branch Mike Jarmy
2009-11-25 16:38 ` Eugene Sajine
2009-11-25 16:47   ` Mike Jarmy
2009-11-25 17:38     ` Avery Pennarun
2009-11-25 18:58     ` Junio C Hamano [this message]
2009-11-25 19:43       ` Mike Jarmy
2009-11-25 23:41         ` Daniel Barkalow
2009-11-25 23:56           ` Andreas Schwab
2009-11-25 16:47 ` Thomas Rast
2009-11-25 16:50 ` Jakub Narebski
2009-11-25 17:40   ` Mike Jarmy
2009-11-25 17:43 ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vaayazb2a.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=euguess@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mjarmy@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox