git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* merging branches with separate but identical history
       [not found] <AANLkTikoDkhKTRmob=B_NYJSYoby0J3Zo-Qp43AU9WfZ@mail.gmail.com>
@ 2010-08-31 21:01 ` Craig de Stigter
  2010-08-31 21:16   ` Jonathan Nieder
  2010-09-01 12:35   ` Henrik Grubbström
  0 siblings, 2 replies; 3+ messages in thread
From: Craig de Stigter @ 2010-08-31 21:01 UTC (permalink / raw)
  To: git

Hi list

I have two branches which start with the same commits, and I want to merge them.
I believe the two branches were individually pulled from the same SVN
repo, so they look like this:

branch1: a--b--c--d--e--f--1--3--5
branch2: a--b--c--d--e--f--2--4--6

If I do:
> git checkout branch1
> git merge branch2
Merge made by recursive

The merge succeeds but the commits in each branch aren't squashed
together (git log shows two commits for each actual commit)
 i.e., now my history looks like this:

a--a--b--b--c--c--d--d--e--e--f--f--1--2--3--4--5--6

Is there a way to do this without the duplicates? (perhaps a way to
mark the branch as merged up to 'f', without actually performing a
merge?)

Thanks
Craig de Stigter
--
Koordinates Ltd
PO Box 1604, Shortland St, Auckland, New Zealand
Phone +64-9-966 0433 Fax +64-9-969 0045
Web http://www.koordinates.com

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

* Re: merging branches with separate but identical history
  2010-08-31 21:01 ` merging branches with separate but identical history Craig de Stigter
@ 2010-08-31 21:16   ` Jonathan Nieder
  2010-09-01 12:35   ` Henrik Grubbström
  1 sibling, 0 replies; 3+ messages in thread
From: Jonathan Nieder @ 2010-08-31 21:16 UTC (permalink / raw)
  To: Craig de Stigter; +Cc: git

Hi,

Craig de Stigter wrote:

> I have two branches which start with the same commits, and I want to merge them.
> I believe the two branches were individually pulled from the same SVN
> repo
[...]
> If I do:
>> git checkout branch1
>> git merge branch2
> Merge made by recursive
> 
> The merge succeeds but the commits in each branch aren't squashed
> together (git log shows two commits for each actual commit)
>  i.e., now my history looks like this:
> 
> a--a--b--b--c--c--d--d--e--e--f--f--1--2--3--4--5--6
> 
> Is there a way to do this without the duplicates? (perhaps a way to
> mark the branch as merged up to 'f', without actually performing a
> merge?)

No.  I would suggest trying

 git cat-file commit a
 git cat-file commit A

where a and A are the two versions of "a" and comparing them.
How do they differ?

If you don't care about superseding the old history and just want
to combine the two branches into a single history, you can try something
like this:

 $ git checkout branch1
 $ git rebase -i branch1~3 --onto branch2~3
 $ git merge branch2

If the history after the fork point is not linear, you can still do
something very similar with grafts.  See git-filter-branch(1) for
details.

Hope that helps,
Jonathan

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

* Re: merging branches with separate but identical history
  2010-08-31 21:01 ` merging branches with separate but identical history Craig de Stigter
  2010-08-31 21:16   ` Jonathan Nieder
@ 2010-09-01 12:35   ` Henrik Grubbström
  1 sibling, 0 replies; 3+ messages in thread
From: Henrik Grubbström @ 2010-09-01 12:35 UTC (permalink / raw)
  To: git

Craig de Stigter <craig.destigter <at> koordinates.com> writes:

> Hi list

Hi.

> I have two branches which start with the same commits, and I want to merge
> them.
> I believe the two branches were individually pulled from the same SVN
> repo, so they look like this:
> 
> branch1: a--b--c--d--e--f--1--3--5
> branch2: a--b--c--d--e--f--2--4--6
[...]
> Is there a way to do this without the duplicates? (perhaps a way to
> mark the branch as merged up to 'f', without actually performing a
> merge?)

Yes, you can use grafts (cf gitrepository-layout(5)) to rewrite the parent
pointer for eg commit 2 from f(2) to f(1).

> Thanks
> Craig de Stigter

-- 
Henrik Grubbström                                         <grubba@grubba.org>
Roxen Internet Software AB                                <grubba@roxen.com>

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

end of thread, other threads:[~2010-09-01 12:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <AANLkTikoDkhKTRmob=B_NYJSYoby0J3Zo-Qp43AU9WfZ@mail.gmail.com>
2010-08-31 21:01 ` merging branches with separate but identical history Craig de Stigter
2010-08-31 21:16   ` Jonathan Nieder
2010-09-01 12:35   ` Henrik Grubbström

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 NNTP newsgroup(s).