{"thread":{"id":"44881","subject":"merge maintaining history","startedAt":"2017-01-14T02:07:36Z","lastAt":"2017-01-26T00:42:03Z","messageCount":9,"participants":["David J. Bakeman","Jacob Keller","Junio C Hamano","Philip Oakley","Jakub Narębski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"309409","messageId":"58798686.5050401@comcast.net","threadId":"44881","inReplyTo":null,"subject":"merge maintaining history","fromName":"David J. Bakeman","fromEmail":"nakuru@comcast.net","sentAt":"2017-01-14T02:01:42Z","receivedAt":"2017-01-14T02:07:36Z","isPatch":false,"sender":{"key":"nakuru@comcast.net","avatar":null},"body":""},{"id":"309433","messageId":"CA+P7+xoF8E55-XDnQT-GN1=hEwwq4pOsz7--P-SCy29C7ST3Hg@mail.gmail.com","threadId":"44881","inReplyTo":"58798686.5050401@comcast.net","subject":"Re: merge maintaining history","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-01-15T06:24:00Z","receivedAt":"2017-01-15T06:24:30Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Fri, Jan 13, 2017 at 6:01 PM, David J. Bakeman <nakuru@comcast.net> wrote:\n> History\n>\n> git cloned a remote repository and made many changes pushing them all to\n> said repository over many months.\n>\n> The powers that be then required me to move project to new repository\n> server did so by pushing local version to new remote saving all history!\n>\n> Now have to merge back to original repository(which has undergone many\n> changes since I split off) but how do I do that without loosing the\n> history of all the commits since the original move?  Note I need to push\n> changes to files that are already in existence.  I found on the web a\n> bunch of ways to insert a whole new directory structure into an existing\n> repository but as I said I need to do it on top of existing files.  Of\n> course I can copy all the files from my local working repository to the\n> cloned remote repository and commit any changes but I loose all the\n> history that way.\n>\n> Thanks.\n\nIf I understand it.. you have two remotes now:\n\nThe \"origin\" remote, which was the original remote you started with.\n\nYou have now a \"new\" remote which you created and pushed to.\n\nSo you want to merge the \"new\" history into the original tree now, so\nyou checkout the original tree, then \"git merge <new-remote>/<branch>\"\nand then fix up any conflicts, and then git commit to create a merge\ncommit that has the new history. Then you could push that to both\ntrees.\n\nI would want a bit more information about your setup before providing\nactual commands.\n\nThanks,\nJake\n"},{"id":"309725","messageId":"5880BB23.8030702@comcast.net","threadId":"44881","inReplyTo":"CA+P7+xoF8E55-XDnQT-GN1=hEwwq4pOsz7--P-SCy29C7ST3Hg@mail.gmail.com","subject":"Re: merge maintaining history","fromName":"David J. Bakeman","fromEmail":"nakuru@comcast.net","sentAt":"2017-01-19T13:12:03Z","receivedAt":"2017-01-19T13:14:26Z","isPatch":false,"sender":{"key":"nakuru@comcast.net","avatar":null},"body":"On 01/14/2017 10:24 PM, Jacob Keller wrote:\n> On Fri, Jan 13, 2017 at 6:01 PM, David J. Bakeman <nakuru@comcast.net> wrote:\n>> History\n>>\n>> git cloned a remote repository and made many changes pushing them all to\n>> said repository over many months.\n>>\n>> The powers that be then required me to move project to new repository\n>> server did so by pushing local version to new remote saving all history!\n>>\n>> Now have to merge back to original repository(which has undergone many\n>> changes since I split off) but how do I do that without loosing the\n>> history of all the commits since the original move?  Note I need to push\n>> changes to files that are already in existence.  I found on the web a\n>> bunch of ways to insert a whole new directory structure into an existing\n>> repository but as I said I need to do it on top of existing files.  Of\n>> course I can copy all the files from my local working repository to the\n>> cloned remote repository and commit any changes but I loose all the\n>> history that way.\n>>\n>> Thanks.\n> If I understand it.. you have two remotes now:\n>\n> The \"origin\" remote, which was the original remote you started with.\n>\n> You have now a \"new\" remote which you created and pushed to.\n>\n> So you want to merge the \"new\" history into the original tree now, so\n> you checkout the original tree, then \"git merge <new-remote>/<branch>\"\n> and then fix up any conflicts, and then git commit to create a merge\n> commit that has the new history. Then you could push that to both\n> trees.\n>\n> I would want a bit more information about your setup before providing\n> actual commands.\nThanks I think that's close but it's a little more complicated I think\n:<(  I don't know if this diagram will work but lets try.\n\noriginal A->B->C->D->E->F\n             \\\nfirst branch  b->c->d->e\n\nnew repo e->f->g->h\n\nNow I need to merge h to F without loosing b through h hopefully.  Yes e\nwas never merged back to the original repo and it's essentially gone now\nso I can't just merge to F or can I?\n \n>\n> Thanks,\n> Jake\n>\n\n\n\nbegin:vcard\nfn:David J. Bakeman\nn:Bakeman;David J.\norg:Nakuru Software Inc.\nadr:;;1504 North 57th Street;Seattle;WA;98103;USA\nemail;internet:nakuru@comcast.net\ntel;work:(206)545-0609\ntel;fax:(206)600-6957\nx-mozilla-html:TRUE\nversion:2.1\nend:vcard\n\n"},{"id":"309790","messageId":"xmqq37gezpz8.fsf@gitster.mtv.corp.google.com","threadId":"44881","inReplyTo":"5880BB23.8030702@comcast.net","subject":"Re: merge maintaining history","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-19T21:42:19Z","receivedAt":"2017-01-19T21:42:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"David J. Bakeman\" <nakuru@comcast.net> writes:\n\n>> So you want to merge the \"new\" history into the original tree now, so\n>> you checkout the original tree, then \"git merge <new-remote>/<branch>\"\n>> and then fix up any conflicts, and then git commit to create a merge\n>> commit that has the new history. Then you could push that to both\n>> trees.\n>>\n>> I would want a bit more information about your setup before providing\n>> actual commands.\n>\n> Thanks I think that's close but it's a little more complicated I think\n> :<(  I don't know if this diagram will work but lets try.\n>\n> original A->B->C->D->E->F\n>              \\\n> first branch  b->c->d->e\n>\n> new repo e->f->g->h\n>\n> Now I need to merge h to F without loosing b through h hopefully.  Yes e\n> was never merged back to the original repo and it's essentially gone now\n> so I can't just merge to F or can I?\n\nWith the picture, I think you mean 'b' is forked from 'B' and the\nfirst branch built 3 more commits on top, leading to 'e'.\n\nYou say \"new repo\" has 'e' thru 'h', and I take it to mean you\nstarted developing on top of the history that leads to 'e' you built\nin the first branch, and \"new repo\" has the resulting history that\nleads to 'h'.\n\nUnless you did something exotic and non-standard, commit 'e' in \"new\nrepo\" would be exactly the same as 'e' sitting on the tip of the\n\"first branch\", so the picture would be more like:\n\n> original A->B->C->D->E->F\n>              \\\n> first branch  b->c->d->e\n>                         \\\n> new repo                 f->g->h\n\nno?  Then merging 'h' into 'F' will pull everything you did since\nyou diverged from the history that leads to 'F', resulting in a\nhistory of this shape:\n\n> original A->B->C->D->E->F----------M\n>              \\                    /\n> first branch  b->c->d->e         /\n>                         \\       /\n> new repo                 f->g->h\n\nIf on the other hand you did something non-standard and exotic to\nrewrite 'e' at the end of \"first branch\" and make a different commit\nthat does not even have any parent in \"new repo\", and the history of\n\"new repo\" originates in such a commit that is not 'e', things will\nbecome messy.  But I didn't think I read you did anything unusual so\na simple \"git checkout F && git merge h\" should give you what you\nwant.\n"},{"id":"309796","messageId":"A2198B6A63224EA79526B7A8BA081B37@PhilipOakley","threadId":"44881","inReplyTo":"5880BB23.8030702@comcast.net","subject":"Re: merge maintaining history","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":null,"receivedAt":"2017-01-19T22:01:55Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"David J. Bakeman\" <nakuru@comcast.net>\n> On 01/14/2017 10:24 PM, Jacob Keller wrote:\n>> On Fri, Jan 13, 2017 at 6:01 PM, David J. Bakeman <nakuru@comcast.net> \n>> wrote:\n>>> History\n>>>\n>>> git cloned a remote repository and made many changes pushing them all to\n>>> said repository over many months.\n>>>\n>>> The powers that be then required me to move project to new repository\n>>> server did so by pushing local version to new remote saving all history!\n>>>\n>>> Now have to merge back to original repository(which has undergone many\n>>> changes since I split off) but how do I do that without loosing the\n>>> history of all the commits since the original move?  Note I need to push\n>>> changes to files that are already in existence.  I found on the web a\n>>> bunch of ways to insert a whole new directory structure into an existing\n>>> repository but as I said I need to do it on top of existing files.  Of\n>>> course I can copy all the files from my local working repository to the\n>>> cloned remote repository and commit any changes but I loose all the\n>>> history that way.\n>>>\n>>> Thanks.\n>> If I understand it.. you have two remotes now:\n>>\n>> The \"origin\" remote, which was the original remote you started with.\n>>\n>> You have now a \"new\" remote which you created and pushed to.\n>>\n>> So you want to merge the \"new\" history into the original tree now, so\n>> you checkout the original tree, then \"git merge <new-remote>/<branch>\"\n>> and then fix up any conflicts, and then git commit to create a merge\n>> commit that has the new history. Then you could push that to both\n>> trees.\n>>\n>> I would want a bit more information about your setup before providing\n>> actual commands.\n> Thanks I think that's close but it's a little more complicated I think\n> :<(  I don't know if this diagram will work but lets try.\n>\n> original A->B->C->D->E->F\n>             \\\n> first branch  b->c->d->e\n>\n> new repo e->f->g->h\n>\n> Now I need to merge h to F without loosing b through h hopefully.  Yes e\n> was never merged back to the original repo and it's essentially gone now\n> so I can't just merge to F or can I?\n\na quick bikeshed..\n\nYou have both repositories, so nothing is lost.\n\nDo note that 'e' commit sha1 in the first branch will be different from the \nsha1 of 'e' commit in the new repo, but both should have the same top level \ntree if they are truly identical.\n\nYou can fetch both repositories into a single common repo so you will have \nan --orphan branch of the new repo.\n\nConsider adding a --allow-empty commit e' to the original repo to note what \nhappens next (and how to do it), which is to use the replace mechanism to \nbridge the gap between the e of the old repo and the e of the new repo by \nmaking e of the new repo replace the e' you just created.\n\nThis will make it look like 'h' is the natural development of 'a'. Even if e \n& e were not tree-same, you will be able to see a diff. You can now merge \n'h' onto 'F' in whatever way you find appropriate to give the right view of \nthe development.\n\nWhen you push this back upstream, note that the 'replace' is local, so \nupstream sees a gap, but that commit e' has the instructions to rebuild the \nlink, should others require it (you may have to push the e' commit \nseparately).\n\n--\nPhilip \n\n"},{"id":"309822","messageId":"38ca43cb-2fc7-0448-352f-7d9413f815c5@gmail.com","threadId":"44881","inReplyTo":"xmqq37gezpz8.fsf@gitster.mtv.corp.google.com","subject":"Re: merge maintaining history","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2017-01-20T11:37:37Z","receivedAt":"2017-01-20T11:37:47Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 19.01.2017 o 22:42, Junio C Hamano pisze:\n> \"David J. Bakeman\" <nakuru@comcast.net> writes:\n \n[...]\n>> Thanks I think that's close but it's a little more complicated I think\n>> :<(  I don't know if this diagram will work but lets try.\n>>\n>> original A->B->C->D->E->F\n>>              \\\n>> first branch  b->c->d->e\n>>\n>> new repo e->f->g->h\n>>\n>> Now I need to merge h to F without loosing b through h hopefully.  Yes e\n>> was never merged back to the original repo and it's essentially gone now\n>> so I can't just merge to F or can I?\n> \n> With the picture, I think you mean 'b' is forked from 'B' and the\n> first branch built 3 more commits on top, leading to 'e'.\n> \n> You say \"new repo\" has 'e' thru 'h', and I take it to mean you\n> started developing on top of the history that leads to 'e' you built\n> in the first branch, and \"new repo\" has the resulting history that\n> leads to 'h'.\n> \n> Unless you did something exotic and non-standard, commit 'e' in \"new\n> repo\" would be exactly the same as 'e' sitting on the tip of the\n> \"first branch\", so the picture would be more like:\n> \n>> original A->B->C->D->E->F\n>>              \\\n>> first branch  b->c->d->e\n>>                         \\\n>> new repo                 f->g->h\n> \n> no?\n\nOn the other hand Git has you covered even if you did something \nnon-standard, like starting new repo from the _state_ of 'e', that\nis you have just copied files and created new repository, having\n'e' (or actually 'e*') as an initial commit.\n\n   original A<-B<-C<-D<-E<-F\n                \\\n   first branch  b<-c<-d<-e\n\n   new repo               e*<-f<-g<-h\n\nNote that arrows are in reverse direction, as it is newer commit\npointing to its parents, not vice versa.\n\nAssuming that you have everything in a single repository, by adding\nboth original and new repo as \"remotes\", you can use 'git replace'\ncommand to replace 'e*' with 'e'.\n\n   original A<-B<-C<-D<-E<-F\n                \\\n   first branch  b<-c<-d<-e\n                           \\\n   new repo                 \\-f<-g<-h\n   (with refs/replace)\n\n>     Then merging 'h' into 'F' will pull everything you did since\n> you diverged from the history that leads to 'F', resulting in a\n> history of this shape:\n> \n>> original A->B->C->D->E->F----------M\n>>              \\                    /\n>> first branch  b->c->d->e         /\n>>                         \\       /\n>> new repo                 f->g->h\n\nThen you would have the above history in repositories that fetched\nrefs/replace/*, and the one below if replacement info is absent:\n\n   original A<-B<-C<-D<-E<-F<-----------M\n                \\                      /\n   first branch  b<-c<-d<-e           /\n                                     /\n   new repo               e*<-f->g->h\n\nBut as Junio said it is highly unlikely that you are in this situation.\n\nHTH\n-- \nJakub Narębski\n\n"},{"id":"309844","messageId":"xmqqpojhy6tf.fsf@gitster.mtv.corp.google.com","threadId":"44881","inReplyTo":"38ca43cb-2fc7-0448-352f-7d9413f815c5@gmail.com","subject":"Re: merge maintaining history","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2017-01-20T17:33:48Z","receivedAt":"2017-01-20T17:33:58Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narębski <jnareb@gmail.com> writes:\n\n> Then you would have the above history in repositories that fetched\n> refs/replace/*, and the one below if replacement info is absent:\n>\n>    original A<-B<-C<-D<-E<-F<-----------M\n>                 \\                      /\n>    first branch  b<-c<-d<-e           /\n>                                      /\n>    new repo               e*<-f->g->h\n>\n> But as Junio said it is highly unlikely that you are in this situation.\n\nI do not think I said it is highly unlikely.  I just said that I\ndidn't read in what David wrote that he did some unusual things, so\nI based my conclusion on that assumption.  People who bring problems\nhere sometimes forget to tell crucial details, and that missing\npiece of information often changes how the situation should be\nhandled.\n"},{"id":"310273","messageId":"5889436A.8000707@comcast.net","threadId":"44881","inReplyTo":"38ca43cb-2fc7-0448-352f-7d9413f815c5@gmail.com","subject":"Re: merge maintaining history","fromName":"David J. Bakeman","fromEmail":"nakuru@comcast.net","sentAt":"2017-01-26T00:31:38Z","receivedAt":"2017-01-26T00:31:45Z","isPatch":false,"sender":{"key":"nakuru@comcast.net","avatar":null},"body":"On 01/20/2017 03:37 AM, Jakub Narębski wrote:\n> W dniu 19.01.2017 o 22:42, Junio C Hamano pisze:\n>> \"David J. Bakeman\" <nakuru@comcast.net> writes:\n>  \n> [...]\n>>> Thanks I think that's close but it's a little more complicated I think\n>>> :<(  I don't know if this diagram will work but lets try.\n>>>\n>>> original A->B->C->D->E->F\n>>>              \\\n>>> first branch  b->c->d->e\n>>>\n>>> new repo e->f->g->h\n>>>\n>>> Now I need to merge h to F without loosing b through h hopefully.  Yes e\n>>> was never merged back to the original repo and it's essentially gone now\n>>> so I can't just merge to F or can I?\n>> With the picture, I think you mean 'b' is forked from 'B' and the\n>> first branch built 3 more commits on top, leading to 'e'.\n>>\n>> You say \"new repo\" has 'e' thru 'h', and I take it to mean you\n>> started developing on top of the history that leads to 'e' you built\n>> in the first branch, and \"new repo\" has the resulting history that\n>> leads to 'h'.\n>>\n>> Unless you did something exotic and non-standard, commit 'e' in \"new\n>> repo\" would be exactly the same as 'e' sitting on the tip of the\n>> \"first branch\", so the picture would be more like:\n>>\n>>> original A->B->C->D->E->F\n>>>              \\\n>>> first branch  b->c->d->e\n>>>                         \\\n>>> new repo                 f->g->h\n>> no?\n> On the other hand Git has you covered even if you did something \n> non-standard, like starting new repo from the _state_ of 'e', that\n> is you have just copied files and created new repository, having\n> 'e' (or actually 'e*') as an initial commit.\n>\n>    original A<-B<-C<-D<-E<-F\n>                 \\\n>    first branch  b<-c<-d<-e\n>\n>    new repo               e*<-f<-g<-h\n>\n> Note that arrows are in reverse direction, as it is newer commit\n> pointing to its parents, not vice versa.\n>\n> Assuming that you have everything in a single repository, by adding\n> both original and new repo as \"remotes\", you can use 'git replace'\n> command to replace 'e*' with 'e'.\n>\n>    original A<-B<-C<-D<-E<-F\n>                 \\\n>    first branch  b<-c<-d<-e\n>                            \\\n>    new repo                 \\-f<-g<-h\n>    (with refs/replace)\n>\n>>     Then merging 'h' into 'F' will pull everything you did since\n>> you diverged from the history that leads to 'F', resulting in a\n>> history of this shape:\n>>\n>>> original A->B->C->D->E->F----------M\n>>>              \\                    /\n>>> first branch  b->c->d->e         /\n>>>                         \\       /\n>>> new repo                 f->g->h\n> Then you would have the above history in repositories that fetched\n> refs/replace/*, and the one below if replacement info is absent:\n>\n>    original A<-B<-C<-D<-E<-F<-----------M\n>                 \\                      /\n>    first branch  b<-c<-d<-e           /\n>                                      /\n>    new repo               e*<-f->g->h\n>\n> But as Junio said it is highly unlikely that you are in this situation.\n>\n> HTH\nOK so what I've done so far is to clone the original then I added\nanother remote connected to new repo.  Then I did git merge newrepo.  It\ndid a bunch of stuff that flashed by really fast and then reported a\nconflict.  Now if I do a git st there are a bunch of files that seem to\nbe already added to a commit and all the files with conflicts which it's\nsays need to be fixed and added.\nI'm still learning git even after using it for several years.  I've\nnever really seen this before.  So the already added files are the ones\nthat git was able to merge mechanically?  If so can I diff those changes\nsome way?  Would I have to un add (reset HEAD) all those files to see\nthe diffs?  Would it have assumed that my changes are to be preferred?\n\nThanks again for all the great help!\n\n\nbegin:vcard\nfn:David J. Bakeman\nn:Bakeman;David J.\norg:Nakuru Software Inc.\nadr:;;1504 North 57th Street;Seattle;WA;98103;USA\nemail;internet:nakuru@comcast.net\ntel;work:(206)545-0609\ntel;fax:(206)600-6957\nx-mozilla-html:TRUE\nversion:2.1\nend:vcard\n\n"},{"id":"310276","messageId":"CA+P7+xrU-ZO981fKCogm3s1gkz6X-8+fcTS4TG0B=_gqAEwNxQ@mail.gmail.com","threadId":"44881","inReplyTo":"5889436A.8000707@comcast.net","subject":"Re: merge maintaining history","fromName":"Jacob Keller","fromEmail":"jacob.keller@gmail.com","sentAt":"2017-01-26T00:41:37Z","receivedAt":"2017-01-26T00:42:03Z","isPatch":false,"sender":{"key":"jacob.keller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/874719?v=4"},"body":"On Wed, Jan 25, 2017 at 4:31 PM, David J. Bakeman <nakuru@comcast.net> wrote:\n> OK so what I've done so far is to clone the original then I added\n> another remote connected to new repo.  Then I did git merge newrepo.  It\n> did a bunch of stuff that flashed by really fast and then reported a\n> conflict.  Now if I do a git st there are a bunch of files that seem to\n> be already added to a commit and all the files with conflicts which it's\n> says need to be fixed and added.\n> I'm still learning git even after using it for several years.  I've\n> never really seen this before.  So the already added files are the ones\n> that git was able to merge mechanically?  If so can I diff those changes\n> some way?  Would I have to un add (reset HEAD) all those files to see\n> the diffs?  Would it have assumed that my changes are to be preferred?\n>\n> Thanks again for all the great help!\n\nTry \"git diff --cached\" to show all the current differences saved in the index.\n\nThanks,\nJake\n"}]}