All of lore.kernel.org
 help / color / mirror / Atom feed
* How to handle a git repository with multiple branches
@ 2010-08-26 11:53 Erez Zilber
  2010-08-26 13:09 ` Joshua Juran
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Erez Zilber @ 2010-08-26 11:53 UTC (permalink / raw)
  To: git

Hi,

My repository has several branches. Each branch is for a separate code
release. Let's assume that I have a branch for V1.0 (branch_1) and a
branch for V2.0 (branch_2).

Some commits are relevant only for branch_1, some are relevant only
for branch_2 and some are relevant for both. For the commits that are
relevant for both branches, I thought about the following solutions:
1. Put these common commits in branch_1 and merge branch_1 into
branch_2. This is bad because it will also merge commits that are
relevant only for branch_1.
2. Cherry-pick the common commits from branch_1 to branch_2. This is
also bad because the commit ID changes, and in case of conflicts, git
is unable to tell that these 2 commits are actually the same commit.
This makes it very difficult to track the changes between branches.

Since there are several other developers and sub-maintainers in this
project which are rebased on both these branches, I don't want to
change the git history of my branches because when I do that,
sub-maintainers and developers lose the reference to their base.

I'm looking for a better solution. Is there any best-practice solution?

Thanks,
Erez

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to handle a git repository with multiple branches
  2010-08-26 11:53 How to handle a git repository with multiple branches Erez Zilber
@ 2010-08-26 13:09 ` Joshua Juran
  2010-08-26 21:17 ` David Ripton
  2010-08-26 23:03 ` Jon Seymour
  2 siblings, 0 replies; 5+ messages in thread
From: Joshua Juran @ 2010-08-26 13:09 UTC (permalink / raw)
  To: Erez Zilber; +Cc: git

On Aug 26, 2010, at 4:53 AM, Erez Zilber wrote:

> My repository has several branches. Each branch is for a separate code
> release. Let's assume that I have a branch for V1.0 (branch_1) and a
> branch for V2.0 (branch_2).
>
> Some commits are relevant only for branch_1, some are relevant only
> for branch_2 and some are relevant for both. For the commits that are
> relevant for both branches, I thought about the following solutions:
> 1. Put these common commits in branch_1 and merge branch_1 into
> branch_2. This is bad because it will also merge commits that are
> relevant only for branch_1.
> 2. Cherry-pick the common commits from branch_1 to branch_2. This is
> also bad because the commit ID changes, and in case of conflicts, git
> is unable to tell that these 2 commits are actually the same commit.
> This makes it very difficult to track the changes between branches.
>
> Since there are several other developers and sub-maintainers in this
> project which are rebased on both these branches, I don't want to
> change the git history of my branches because when I do that,
> sub-maintainers and developers lose the reference to their base.
>
> I'm looking for a better solution. Is there any best-practice  
> solution?

Off the top of my head, store each patch in its own branch, based off  
of a commit common to both branch_1 and branch_2.  Then merge patch  
branches into release branches as appropriate.  You might consider  
also doing this for patches unique to a release, not just the common  
ones.

Josh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to handle a git repository with multiple branches
  2010-08-26 11:53 How to handle a git repository with multiple branches Erez Zilber
  2010-08-26 13:09 ` Joshua Juran
@ 2010-08-26 21:17 ` David Ripton
  2010-08-26 23:03 ` Jon Seymour
  2 siblings, 0 replies; 5+ messages in thread
From: David Ripton @ 2010-08-26 21:17 UTC (permalink / raw)
  To: Erez Zilber; +Cc: git

On 08/26/10 07:53, Erez Zilber wrote:

> Some commits are relevant only for branch_1, some are relevant only
> for branch_2 and some are relevant for both. For the commits that are
> relevant for both branches, I thought about the following solutions:
> 1. Put these common commits in branch_1 and merge branch_1 into
> branch_2. This is bad because it will also merge commits that are
> relevant only for branch_1.
> 2. Cherry-pick the common commits from branch_1 to branch_2. This is
> also bad because the commit ID changes, and in case of conflicts, git
> is unable to tell that these 2 commits are actually the same commit.
> This makes it very difficult to track the changes between branches.
>
> Since there are several other developers and sub-maintainers in this
> project which are rebased on both these branches, I don't want to
> change the git history of my branches because when I do that,
> sub-maintainers and developers lose the reference to their base.
>
> I'm looking for a better solution. Is there any best-practice solution?

Fix bugs in the oldest release branch to which the fix applies.  Then 
merge the old branches into the new ones.

When this doesn't work, then you have to cherry pick.

-- 
David Ripton    dripton@ripton.net

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to handle a git repository with multiple branches
  2010-08-26 11:53 How to handle a git repository with multiple branches Erez Zilber
  2010-08-26 13:09 ` Joshua Juran
  2010-08-26 21:17 ` David Ripton
@ 2010-08-26 23:03 ` Jon Seymour
  2010-08-31  7:21   ` Erez Zilber
  2 siblings, 1 reply; 5+ messages in thread
From: Jon Seymour @ 2010-08-26 23:03 UTC (permalink / raw)
  To: Erez Zilber; +Cc: git

On Thu, Aug 26, 2010 at 9:53 PM, Erez Zilber <erezzi.list@gmail.com> wrote:
> Hi,
>
> My repository has several branches. Each branch is for a separate code
> release. Let's assume that I have a branch for V1.0 (branch_1) and a
> branch for V2.0 (branch_2).
>
> Some commits are relevant only for branch_1, some are relevant only
> for branch_2 and some are relevant for both. For the commits that are
> relevant for both branches, I thought about the following solutions:
> 1. Put these common commits in branch_1 and merge branch_1 into
> branch_2. This is bad because it will also merge commits that are
> relevant only for branch_1.
> 2. Cherry-pick the common commits from branch_1 to branch_2. This is
> also bad because the commit ID changes, and in case of conflicts, git
> is unable to tell that these 2 commits are actually the same commit.
> This makes it very difficult to track the changes between branches.
>
> Since there are several other developers and sub-maintainers in this
> project which are rebased on both these branches, I don't want to
> change the git history of my branches because when I do that,
> sub-maintainers and developers lose the reference to their base.
>
> I'm looking for a better solution. Is there any best-practice solution?
>

As Josh pointed out in another post, the key to sharing commits across
branches is to ensure that the commits that you intend to share
between branches should always be based on a commit that both branches
have in common. That way, when you eventually merge the commit into
the branch the only history it drags in is the history associated with
the patch itself.

This requires a slight shift in mind set - don't automatically assume
the right thing to do is develop a patch is on the tip of branch_1. If
the branch_1 does contain other stuff that you are not intending to
merge into branch_2, this is probably the wrong thing to do.

What I tend to do (as described here
http://permalink.gmane.org/gmane.comp.version-control.git/153168), is
to
develop my fixes on  the tip of private integration branch (which I
never share), then rebase them onto a suitable base common to all
potential delivery targets later. This works for me, because there
isn't typically much divergence in the files I touch between branches.
 It might not work so well in cases where there is significant
divergence.

jon.

> Thanks,
> Erez
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to handle a git repository with multiple branches
  2010-08-26 23:03 ` Jon Seymour
@ 2010-08-31  7:21   ` Erez Zilber
  0 siblings, 0 replies; 5+ messages in thread
From: Erez Zilber @ 2010-08-31  7:21 UTC (permalink / raw)
  To: Jon Seymour; +Cc: git

On Fri, Aug 27, 2010 at 2:03 AM, Jon Seymour <jon.seymour@gmail.com> wrote:
> On Thu, Aug 26, 2010 at 9:53 PM, Erez Zilber <erezzi.list@gmail.com> wrote:
>> Hi,
>>
>> My repository has several branches. Each branch is for a separate code
>> release. Let's assume that I have a branch for V1.0 (branch_1) and a
>> branch for V2.0 (branch_2).
>>
>> Some commits are relevant only for branch_1, some are relevant only
>> for branch_2 and some are relevant for both. For the commits that are
>> relevant for both branches, I thought about the following solutions:
>> 1. Put these common commits in branch_1 and merge branch_1 into
>> branch_2. This is bad because it will also merge commits that are
>> relevant only for branch_1.
>> 2. Cherry-pick the common commits from branch_1 to branch_2. This is
>> also bad because the commit ID changes, and in case of conflicts, git
>> is unable to tell that these 2 commits are actually the same commit.
>> This makes it very difficult to track the changes between branches.
>>
>> Since there are several other developers and sub-maintainers in this
>> project which are rebased on both these branches, I don't want to
>> change the git history of my branches because when I do that,
>> sub-maintainers and developers lose the reference to their base.
>>
>> I'm looking for a better solution. Is there any best-practice solution?
>>
>
> As Josh pointed out in another post, the key to sharing commits across
> branches is to ensure that the commits that you intend to share
> between branches should always be based on a commit that both branches
> have in common. That way, when you eventually merge the commit into
> the branch the only history it drags in is the history associated with
> the patch itself.
>
> This requires a slight shift in mind set - don't automatically assume
> the right thing to do is develop a patch is on the tip of branch_1. If
> the branch_1 does contain other stuff that you are not intending to
> merge into branch_2, this is probably the wrong thing to do.
>
> What I tend to do (as described here
> http://permalink.gmane.org/gmane.comp.version-control.git/153168), is
> to
> develop my fixes on  the tip of private integration branch (which I
> never share), then rebase them onto a suitable base common to all
> potential delivery targets later. This works for me, because there
> isn't typically much divergence in the files I touch between branches.
>  It might not work so well in cases where there is significant
> divergence.
>
> jon.
>

Thanks for the answers.

Erez

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-08-31  7:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-26 11:53 How to handle a git repository with multiple branches Erez Zilber
2010-08-26 13:09 ` Joshua Juran
2010-08-26 21:17 ` David Ripton
2010-08-26 23:03 ` Jon Seymour
2010-08-31  7:21   ` Erez Zilber

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.