git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "David J. Bakeman" <nakuru@comcast.net>
Cc: Jacob Keller <jacob.keller@gmail.com>,
	Git mailing list <git@vger.kernel.org>
Subject: Re: merge maintaining history
Date: Thu, 19 Jan 2017 13:42:19 -0800	[thread overview]
Message-ID: <xmqq37gezpz8.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <5880BB23.8030702@comcast.net> (David J. Bakeman's message of "Thu, 19 Jan 2017 05:12:03 -0800")

"David J. Bakeman" <nakuru@comcast.net> writes:

>> So you want to merge the "new" history into the original tree now, so
>> you checkout the original tree, then "git merge <new-remote>/<branch>"
>> and then fix up any conflicts, and then git commit to create a merge
>> commit that has the new history. Then you could push that to both
>> trees.
>>
>> I would want a bit more information about your setup before providing
>> actual commands.
>
> Thanks I think that's close but it's a little more complicated I think
> :<(  I don't know if this diagram will work but lets try.
>
> original A->B->C->D->E->F
>              \
> first branch  b->c->d->e
>
> new repo e->f->g->h
>
> Now I need to merge h to F without loosing b through h hopefully.  Yes e
> was never merged back to the original repo and it's essentially gone now
> so I can't just merge to F or can I?

With the picture, I think you mean 'b' is forked from 'B' and the
first branch built 3 more commits on top, leading to 'e'.

You say "new repo" has 'e' thru 'h', and I take it to mean you
started developing on top of the history that leads to 'e' you built
in the first branch, and "new repo" has the resulting history that
leads to 'h'.

Unless you did something exotic and non-standard, commit 'e' in "new
repo" would be exactly the same as 'e' sitting on the tip of the
"first branch", so the picture would be more like:

> original A->B->C->D->E->F
>              \
> first branch  b->c->d->e
>                         \
> new repo                 f->g->h

no?  Then merging 'h' into 'F' will pull everything you did since
you diverged from the history that leads to 'F', resulting in a
history of this shape:

> original A->B->C->D->E->F----------M
>              \                    /
> first branch  b->c->d->e         /
>                         \       /
> new repo                 f->g->h

If on the other hand you did something non-standard and exotic to
rewrite 'e' at the end of "first branch" and make a different commit
that does not even have any parent in "new repo", and the history of
"new repo" originates in such a commit that is not 'e', things will
become messy.  But I didn't think I read you did anything unusual so
a simple "git checkout F && git merge h" should give you what you
want.

  reply	other threads:[~2017-01-19 21:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-14  2:01 merge maintaining history David J. Bakeman
2017-01-15  6:24 ` Jacob Keller
2017-01-19 13:12   ` David J. Bakeman
2017-01-19 21:42     ` Junio C Hamano [this message]
2017-01-20 11:37       ` Jakub Narębski
2017-01-20 17:33         ` Junio C Hamano
2017-01-26  0:31         ` David J. Bakeman
2017-01-26  0:41           ` Jacob Keller
2017-01-19 21:58     ` Philip Oakley

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=xmqq37gezpz8.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=jacob.keller@gmail.com \
    --cc=nakuru@comcast.net \
    /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).