git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* merge maintaining history
@ 2017-01-14  2:01 David J. Bakeman
  2017-01-15  6:24 ` Jacob Keller
  0 siblings, 1 reply; 9+ messages in thread
From: David J. Bakeman @ 2017-01-14  2:01 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 854 bytes --]

History

git cloned a remote repository and made many changes pushing them all to
said repository over many months.

The powers that be then required me to move project to new repository
server did so by pushing local version to new remote saving all history!

Now have to merge back to original repository(which has undergone many
changes since I split off) but how do I do that without loosing the
history of all the commits since the original move?  Note I need to push
changes to files that are already in existence.  I found on the web a
bunch of ways to insert a whole new directory structure into an existing
repository but as I said I need to do it on top of existing files.  Of
course I can copy all the files from my local working repository to the
cloned remote repository and commit any changes but I loose all the
history that way.

Thanks.

[-- Attachment #2: nakuru.vcf --]
[-- Type: text/x-vcard, Size: 248 bytes --]

begin:vcard
fn:David J. Bakeman
n:Bakeman;David J.
org:Nakuru Software Inc.
adr:;;1504 North 57th Street;Seattle;WA;98103;USA
email;internet:nakuru@comcast.net
tel;work:(206)545-0609
tel;fax:(206)600-6957
x-mozilla-html:TRUE
version:2.1
end:vcard


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

* Re: merge maintaining history
  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
  0 siblings, 1 reply; 9+ messages in thread
From: Jacob Keller @ 2017-01-15  6:24 UTC (permalink / raw)
  To: David J. Bakeman; +Cc: Git mailing list

On Fri, Jan 13, 2017 at 6:01 PM, David J. Bakeman <nakuru@comcast.net> wrote:
> History
>
> git cloned a remote repository and made many changes pushing them all to
> said repository over many months.
>
> The powers that be then required me to move project to new repository
> server did so by pushing local version to new remote saving all history!
>
> Now have to merge back to original repository(which has undergone many
> changes since I split off) but how do I do that without loosing the
> history of all the commits since the original move?  Note I need to push
> changes to files that are already in existence.  I found on the web a
> bunch of ways to insert a whole new directory structure into an existing
> repository but as I said I need to do it on top of existing files.  Of
> course I can copy all the files from my local working repository to the
> cloned remote repository and commit any changes but I loose all the
> history that way.
>
> Thanks.

If I understand it.. you have two remotes now:

The "origin" remote, which was the original remote you started with.

You have now a "new" remote which you created and pushed to.

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,
Jake

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

* Re: merge maintaining history
  2017-01-15  6:24 ` Jacob Keller
@ 2017-01-19 13:12   ` David J. Bakeman
  2017-01-19 21:42     ` Junio C Hamano
  2017-01-19 21:58     ` Philip Oakley
  0 siblings, 2 replies; 9+ messages in thread
From: David J. Bakeman @ 2017-01-19 13:12 UTC (permalink / raw)
  To: Jacob Keller; +Cc: Git mailing list

[-- Attachment #1: Type: text/plain, Size: 2031 bytes --]

On 01/14/2017 10:24 PM, Jacob Keller wrote:
> On Fri, Jan 13, 2017 at 6:01 PM, David J. Bakeman <nakuru@comcast.net> wrote:
>> History
>>
>> git cloned a remote repository and made many changes pushing them all to
>> said repository over many months.
>>
>> The powers that be then required me to move project to new repository
>> server did so by pushing local version to new remote saving all history!
>>
>> Now have to merge back to original repository(which has undergone many
>> changes since I split off) but how do I do that without loosing the
>> history of all the commits since the original move?  Note I need to push
>> changes to files that are already in existence.  I found on the web a
>> bunch of ways to insert a whole new directory structure into an existing
>> repository but as I said I need to do it on top of existing files.  Of
>> course I can copy all the files from my local working repository to the
>> cloned remote repository and commit any changes but I loose all the
>> history that way.
>>
>> Thanks.
> If I understand it.. you have two remotes now:
>
> The "origin" remote, which was the original remote you started with.
>
> You have now a "new" remote which you created and pushed to.
>
> 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?
 
>
> Thanks,
> Jake
>


[-- Attachment #2: nakuru.vcf --]
[-- Type: text/x-vcard, Size: 248 bytes --]

begin:vcard
fn:David J. Bakeman
n:Bakeman;David J.
org:Nakuru Software Inc.
adr:;;1504 North 57th Street;Seattle;WA;98103;USA
email;internet:nakuru@comcast.net
tel;work:(206)545-0609
tel;fax:(206)600-6957
x-mozilla-html:TRUE
version:2.1
end:vcard


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

* Re: merge maintaining history
  2017-01-19 13:12   ` David J. Bakeman
@ 2017-01-19 21:42     ` Junio C Hamano
  2017-01-20 11:37       ` Jakub Narębski
  2017-01-19 21:58     ` Philip Oakley
  1 sibling, 1 reply; 9+ messages in thread
From: Junio C Hamano @ 2017-01-19 21:42 UTC (permalink / raw)
  To: David J. Bakeman; +Cc: Jacob Keller, Git mailing list

"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.

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

* Re: merge maintaining history
  2017-01-19 13:12   ` David J. Bakeman
  2017-01-19 21:42     ` Junio C Hamano
@ 2017-01-19 21:58     ` Philip Oakley
  1 sibling, 0 replies; 9+ messages in thread
From: Philip Oakley @ 2017-01-19 21:58 UTC (permalink / raw)
  To: Jacob Keller, David J. Bakeman; +Cc: Git mailing list

From: "David J. Bakeman" <nakuru@comcast.net>
> On 01/14/2017 10:24 PM, Jacob Keller wrote:
>> On Fri, Jan 13, 2017 at 6:01 PM, David J. Bakeman <nakuru@comcast.net> 
>> wrote:
>>> History
>>>
>>> git cloned a remote repository and made many changes pushing them all to
>>> said repository over many months.
>>>
>>> The powers that be then required me to move project to new repository
>>> server did so by pushing local version to new remote saving all history!
>>>
>>> Now have to merge back to original repository(which has undergone many
>>> changes since I split off) but how do I do that without loosing the
>>> history of all the commits since the original move?  Note I need to push
>>> changes to files that are already in existence.  I found on the web a
>>> bunch of ways to insert a whole new directory structure into an existing
>>> repository but as I said I need to do it on top of existing files.  Of
>>> course I can copy all the files from my local working repository to the
>>> cloned remote repository and commit any changes but I loose all the
>>> history that way.
>>>
>>> Thanks.
>> If I understand it.. you have two remotes now:
>>
>> The "origin" remote, which was the original remote you started with.
>>
>> You have now a "new" remote which you created and pushed to.
>>
>> 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?

a quick bikeshed..

You have both repositories, so nothing is lost.

Do note that 'e' commit sha1 in the first branch will be different from the 
sha1 of 'e' commit in the new repo, but both should have the same top level 
tree if they are truly identical.

You can fetch both repositories into a single common repo so you will have 
an --orphan branch of the new repo.

Consider adding a --allow-empty commit e' to the original repo to note what 
happens next (and how to do it), which is to use the replace mechanism to 
bridge the gap between the e of the old repo and the e of the new repo by 
making e of the new repo replace the e' you just created.

This will make it look like 'h' is the natural development of 'a'. Even if e 
& e were not tree-same, you will be able to see a diff. You can now merge 
'h' onto 'F' in whatever way you find appropriate to give the right view of 
the development.

When you push this back upstream, note that the 'replace' is local, so 
upstream sees a gap, but that commit e' has the instructions to rebuild the 
link, should others require it (you may have to push the e' commit 
separately).

--
Philip 


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

* Re: merge maintaining history
  2017-01-19 21:42     ` Junio C Hamano
@ 2017-01-20 11:37       ` Jakub Narębski
  2017-01-20 17:33         ` Junio C Hamano
  2017-01-26  0:31         ` David J. Bakeman
  0 siblings, 2 replies; 9+ messages in thread
From: Jakub Narębski @ 2017-01-20 11:37 UTC (permalink / raw)
  To: Junio C Hamano, David J. Bakeman; +Cc: Jacob Keller, Git mailing list

W dniu 19.01.2017 o 22:42, Junio C Hamano pisze:
> "David J. Bakeman" <nakuru@comcast.net> writes:
 
[...]
>> 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?

On the other hand Git has you covered even if you did something 
non-standard, like starting new repo from the _state_ of 'e', that
is you have just copied files and created new repository, having
'e' (or actually 'e*') as an initial commit.

   original A<-B<-C<-D<-E<-F
                \
   first branch  b<-c<-d<-e

   new repo               e*<-f<-g<-h

Note that arrows are in reverse direction, as it is newer commit
pointing to its parents, not vice versa.

Assuming that you have everything in a single repository, by adding
both original and new repo as "remotes", you can use 'git replace'
command to replace 'e*' with 'e'.

   original A<-B<-C<-D<-E<-F
                \
   first branch  b<-c<-d<-e
                           \
   new repo                 \-f<-g<-h
   (with refs/replace)

>     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

Then you would have the above history in repositories that fetched
refs/replace/*, and the one below if replacement info is absent:

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

But as Junio said it is highly unlikely that you are in this situation.

HTH
-- 
Jakub Narębski


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

* Re: merge maintaining history
  2017-01-20 11:37       ` Jakub Narębski
@ 2017-01-20 17:33         ` Junio C Hamano
  2017-01-26  0:31         ` David J. Bakeman
  1 sibling, 0 replies; 9+ messages in thread
From: Junio C Hamano @ 2017-01-20 17:33 UTC (permalink / raw)
  To: Jakub Narębski; +Cc: David J. Bakeman, Jacob Keller, Git mailing list

Jakub Narębski <jnareb@gmail.com> writes:

> Then you would have the above history in repositories that fetched
> refs/replace/*, and the one below if replacement info is absent:
>
>    original A<-B<-C<-D<-E<-F<-----------M
>                 \                      /
>    first branch  b<-c<-d<-e           /
>                                      /
>    new repo               e*<-f->g->h
>
> But as Junio said it is highly unlikely that you are in this situation.

I do not think I said it is highly unlikely.  I just said that I
didn't read in what David wrote that he did some unusual things, so
I based my conclusion on that assumption.  People who bring problems
here sometimes forget to tell crucial details, and that missing
piece of information often changes how the situation should be
handled.

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

* Re: merge maintaining history
  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
  1 sibling, 1 reply; 9+ messages in thread
From: David J. Bakeman @ 2017-01-26  0:31 UTC (permalink / raw)
  To: Jakub Narębski, Junio C Hamano; +Cc: Jacob Keller, Git mailing list

[-- Attachment #1: Type: text/plain, Size: 3731 bytes --]

On 01/20/2017 03:37 AM, Jakub Narębski wrote:
> W dniu 19.01.2017 o 22:42, Junio C Hamano pisze:
>> "David J. Bakeman" <nakuru@comcast.net> writes:
>  
> [...]
>>> 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?
> On the other hand Git has you covered even if you did something 
> non-standard, like starting new repo from the _state_ of 'e', that
> is you have just copied files and created new repository, having
> 'e' (or actually 'e*') as an initial commit.
>
>    original A<-B<-C<-D<-E<-F
>                 \
>    first branch  b<-c<-d<-e
>
>    new repo               e*<-f<-g<-h
>
> Note that arrows are in reverse direction, as it is newer commit
> pointing to its parents, not vice versa.
>
> Assuming that you have everything in a single repository, by adding
> both original and new repo as "remotes", you can use 'git replace'
> command to replace 'e*' with 'e'.
>
>    original A<-B<-C<-D<-E<-F
>                 \
>    first branch  b<-c<-d<-e
>                            \
>    new repo                 \-f<-g<-h
>    (with refs/replace)
>
>>     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
> Then you would have the above history in repositories that fetched
> refs/replace/*, and the one below if replacement info is absent:
>
>    original A<-B<-C<-D<-E<-F<-----------M
>                 \                      /
>    first branch  b<-c<-d<-e           /
>                                      /
>    new repo               e*<-f->g->h
>
> But as Junio said it is highly unlikely that you are in this situation.
>
> HTH
OK so what I've done so far is to clone the original then I added
another remote connected to new repo.  Then I did git merge newrepo.  It
did a bunch of stuff that flashed by really fast and then reported a
conflict.  Now if I do a git st there are a bunch of files that seem to
be already added to a commit and all the files with conflicts which it's
says need to be fixed and added.
I'm still learning git even after using it for several years.  I've
never really seen this before.  So the already added files are the ones
that git was able to merge mechanically?  If so can I diff those changes
some way?  Would I have to un add (reset HEAD) all those files to see
the diffs?  Would it have assumed that my changes are to be preferred?

Thanks again for all the great help!

[-- Attachment #2: nakuru.vcf --]
[-- Type: text/x-vcard, Size: 248 bytes --]

begin:vcard
fn:David J. Bakeman
n:Bakeman;David J.
org:Nakuru Software Inc.
adr:;;1504 North 57th Street;Seattle;WA;98103;USA
email;internet:nakuru@comcast.net
tel;work:(206)545-0609
tel;fax:(206)600-6957
x-mozilla-html:TRUE
version:2.1
end:vcard


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

* Re: merge maintaining history
  2017-01-26  0:31         ` David J. Bakeman
@ 2017-01-26  0:41           ` Jacob Keller
  0 siblings, 0 replies; 9+ messages in thread
From: Jacob Keller @ 2017-01-26  0:41 UTC (permalink / raw)
  To: David J. Bakeman; +Cc: Jakub Narębski, Junio C Hamano, Git mailing list

On Wed, Jan 25, 2017 at 4:31 PM, David J. Bakeman <nakuru@comcast.net> wrote:
> OK so what I've done so far is to clone the original then I added
> another remote connected to new repo.  Then I did git merge newrepo.  It
> did a bunch of stuff that flashed by really fast and then reported a
> conflict.  Now if I do a git st there are a bunch of files that seem to
> be already added to a commit and all the files with conflicts which it's
> says need to be fixed and added.
> I'm still learning git even after using it for several years.  I've
> never really seen this before.  So the already added files are the ones
> that git was able to merge mechanically?  If so can I diff those changes
> some way?  Would I have to un add (reset HEAD) all those files to see
> the diffs?  Would it have assumed that my changes are to be preferred?
>
> Thanks again for all the great help!

Try "git diff --cached" to show all the current differences saved in the index.

Thanks,
Jake

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

end of thread, other threads:[~2017-01-26  0:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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

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).