git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Patrick Sabin <patrick.just4fun@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: git workflow - merging upwards
Date: Thu, 16 Aug 2012 13:43:23 -0700	[thread overview]
Message-ID: <7vboia1sb8.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <502D4EAE.9010704@gmail.com> (Patrick Sabin's message of "Thu, 16 Aug 2012 21:49:02 +0200")

Patrick Sabin <patrick.just4fun@gmail.com> writes:

> I read through gitworkflows and want to use the Merge Upwards rule in
> my projects:
>
> "Always commit your fixes to the oldest supported branch that require
> them. Then (periodically) merge the integration branches upwards into
> each other."
>
> This looks great but I have some trouble in the case if I want to have
> a change in an older branch and don't want to propagate the change to
> the newer branches. Let's say I have a v1.1 and a v1.2 and now a have
> a bug fix/workaround which only affects version v1.1 but not v1.2. If
> I commit to v1.1 then the periodical merge would merge the change to
> v1.2 which is what I don't want.
>
> Any ideas/workarounds for that problem?

The document may describe the "upwards" in a bit too simplified way
for readability.  If you have two fixes to 1.1, one applicable only
to 1.1 and the other applicable to both, you would fork them from
tip of maint-1.1, like so:

    git checkout -b fix-1.1-only maint-1.1; do your work and commit
    git checkout -b fix-1.1-onwards maint-1.1; do your work and commit

and when they are proven to be good, you would merge both of them to
maint-1.1 branch:

    git checkout maint-1.1
    git merge fix-1.1-only
    git merge fix-1.1-onwards

But merging the resulting maint-1.1 into maint-1.2 will pull the
history and the change of fix-1.1-only that you do not want to have
in maint-1.2.  You want the history so that later merge will not
pull it to maint-1.2, but you do not want the change.

The first thing to think about is if fix-1.1-only is really a "fix
that only should go to maint-1.1".

If the change is only for 1.1.x release (e.g. update version number
from 1.1.4 to 1.1.5), you may not even want to have such a change
directly on the maint-1.1 branch in the first place.  You would
rather want to have release-1.1 branch that is forked from maint-1.1
branch, that contains the whole of maint-1.1 branch, and also
contains the "update version number from 1.1.x to 1.1.y" changes
that are not in the maint-1.1 branch [*1*].

That arrangement may be sufficient to allow you merge maint-1.1 to
maint-1.2 sanely.

Otherwise, you would fork another branch after merging fix-1.1-*
branches to maint-1.1 to merge it upwards.  After these two merges
illustrated above, while still on maint-1.1, you would do:

    git checkout -B merge-1.1-to-1.2 maint-1.1
    git revert -m 1 maint-1.1~1 ;# revert the fix-1.1-only merge

which would result in a state as if you merged fix-1.1-onwards but
not fix-1.1-only to the original maint-1.1 branch.  But the history
of this branch contains both fix-1.1-only and fix-1.1-onwards.

And merge that result to maint-1.2, i.e.

    git checkout maint-1.2
    git merge merge-1.1-to-1.2
    git branch -d merge-1.1-to-1.2

That way, future merges from maint-1.1 to maint-1.2 will not drag
the change of fix-1.1-only.


[Footnote]

*1* This principle applies not just to "release numbers". If you
want both maint-1.1 and maint-1.2 as generic two codebases, tweaks
meant only for customers of maint-1.1 track should *not* go to
maint-1.1, but customer-1.1 branch that forks from maint-1.1. That
way, you can keep the generic branches clean from "this is only for
that branch" kind of changes.

  reply	other threads:[~2012-08-16 20:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-16 19:49 git workflow - merging upwards Patrick Sabin
2012-08-16 20:43 ` Junio C Hamano [this message]
2012-08-17  8:14   ` Patrick Sabin

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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=7vboia1sb8.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=patrick.just4fun@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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).