{"thread":{"id":"45067","subject":"subtree merging fails","startedAt":"2017-02-07T08:16:52Z","lastAt":"2017-02-08T10:53:22Z","messageCount":4,"participants":["Stavros Liaskos","Samuel Lijin","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"310971","messageId":"CAEXhnECi3LvSA92dSjL5PZ1Lx9p1PWELS04nmfJW=8K9o4T-0Q@mail.gmail.com","threadId":"45067","inReplyTo":null,"subject":"subtree merging fails","fromName":"Stavros Liaskos","fromEmail":"st.liaskos@gmail.com","sentAt":"2017-02-07T08:16:46Z","receivedAt":"2017-02-07T08:16:52Z","isPatch":false,"sender":{"key":"st.liaskos@gmail.com","avatar":null},"body":"Following the instructions here:\nhttps://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging\nwill lead to an error.\n\nIn particular, if the subtree is merged and then updated, this command\nthat is supposed to update the local subtree fails with a fatal:\nrefusing to merge unrelated histories error.\n\n$ git merge --squash -s subtree --no-commit rack_branch\n\nA workaround could be using the --allow-unrelated-histories option\n\n$ git merge --squash --allow-unrelated-histories -s subtree\n--no-commit rack_branch\n\nBut this completely destroys my project by pushing the subtree\ncontents into a completely irrelevant directory in my project (no in\nthe subtree).\n\nAny ideas??\n\nhttps://github.com/git/git-scm.com/issues/896#issuecomment-277587626\n"},{"id":"310986","messageId":"CAJZjrdU3toam4tDwXBu1Q3UAZm-kML3CzMrsMoJ_2jsGJ3vWrQ@mail.gmail.com","threadId":"45067","inReplyTo":"CAEXhnECi3LvSA92dSjL5PZ1Lx9p1PWELS04nmfJW=8K9o4T-0Q@mail.gmail.com","subject":"Re: subtree merging fails","fromName":"Samuel Lijin","fromEmail":"sxlijin@gmail.com","sentAt":"2017-02-07T14:59:06Z","receivedAt":"2017-02-07T14:59:52Z","isPatch":false,"sender":{"key":"sxlijin@gmail.com","avatar":"https://gravatar.com/avatar/01777bf1eae64e2b4dca97dcac182a6abbcf6fd8cb4d5b8fa33edf9f8cc21746?d=mp&s=160"},"body":"Have you tried using (without -s subtree) -X subtree=path/to/add/subtree/at?\n\nFrom the man page:\n\n          subtree[=<path>]\n               This option is a more advanced form of subtree\nstrategy, where the strategy\n               makes a guess on how two trees must be shifted to match\nwith each other when\n               merging. Instead, the specified path is prefixed (or\nstripped from the\n               beginning) to make the shape of two trees to match.\n\nOn Tue, Feb 7, 2017 at 2:16 AM, Stavros Liaskos <st.liaskos@gmail.com> wrote:\n> Following the instructions here:\n> https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging\n> will lead to an error.\n>\n> In particular, if the subtree is merged and then updated, this command\n> that is supposed to update the local subtree fails with a fatal:\n> refusing to merge unrelated histories error.\n>\n> $ git merge --squash -s subtree --no-commit rack_branch\n>\n> A workaround could be using the --allow-unrelated-histories option\n>\n> $ git merge --squash --allow-unrelated-histories -s subtree\n> --no-commit rack_branch\n>\n> But this completely destroys my project by pushing the subtree\n> contents into a completely irrelevant directory in my project (no in\n> the subtree).\n>\n> Any ideas??\n>\n> https://github.com/git/git-scm.com/issues/896#issuecomment-277587626\n"},{"id":"310998","messageId":"20170207184437.c6uuuxcmhi434vbc@gmail.com","threadId":"45067","inReplyTo":"CAJZjrdU3toam4tDwXBu1Q3UAZm-kML3CzMrsMoJ_2jsGJ3vWrQ@mail.gmail.com","subject":"Re: subtree merging fails","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2017-02-07T18:44:37Z","receivedAt":"2017-02-07T19:48:50Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Tue, Feb 07, 2017 at 08:59:06AM -0600, Samuel Lijin wrote:\n> Have you tried using (without -s subtree) -X subtree=path/to/add/subtree/at?\n> \n> From the man page:\n> \n>           subtree[=<path>]\n>                This option is a more advanced form of subtree\n> strategy, where the strategy\n>                makes a guess on how two trees must be shifted to match\n> with each other when\n>                merging. Instead, the specified path is prefixed (or\n> stripped from the\n>                beginning) to make the shape of two trees to match.\n\nI'm not 100% certain, but it's highly likely that the subtree=<prefix>\nargument needs to include a trailing slash \"/\" in the prefix,\notherwise files will be named e.g. \"fooREADME\" instead of\n\"foo/README\" when prefix=foo.\n\nThese days I would steer users towards the \"git-subtree\" command in\ncontrib/ so that users don't need to deal with these details.  It\nhandles all of this stuff for you.\n\nhttps://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt\n\nhttps://github.com/git/git/tree/master/contrib/subtree\n\nUpdating the progit book to also mention git-subtree, in addition to the\nlow-level methods, would probably be a good user-centric change.\n-- \nDavid\n"},{"id":"311049","messageId":"CAEXhnEBaH39qavUZRNcOp0BDgqADrtOmamE_DH-Ch5tcH=hADA@mail.gmail.com","threadId":"45067","inReplyTo":"20170207184437.c6uuuxcmhi434vbc@gmail.com","subject":"Re: subtree merging fails","fromName":"Stavros Liaskos","fromEmail":"st.liaskos@gmail.com","sentAt":"2017-02-08T10:42:19Z","receivedAt":"2017-02-08T10:53:22Z","isPatch":false,"sender":{"key":"st.liaskos@gmail.com","avatar":null},"body":"@Samuel Lijin\nI tried now and I get:\n\"merge: branch_name - not something we can merge\".\nMaybe that is something easy to fix but currently I am using a\nworkaround script so I am not putting any more effort at this at the\nmoment.\n\n@David Aguilar\nThat's true but the trailing slash is already there. This commands\nlooks promising. An update would be GREAT!\n\nFYI that's the script I am using to address this problem:\n\n#!/bin/bash\n\nfunction initial {\n  if git remote | grep -q lisa_remote\n  then\n    echo \"Subtree delete & update\"\n    git checkout lisa_branch\n    git pull\n    git checkout master\n    git merge --squash -s subtree --no-commit lisa_branch\n    git merge --squash --allow-unrelated-histories -s subtree\n--no-commit lisa_branch\n  else\n    echo \"Add subtree\"\n    git remote add lisa_remote git@xxxxxxxx:lisa/lisa.git\n    git fetch lisa_remote\n    git checkout -b lisa_branch lisa_remote/master\n    git checkout master\n    git read-tree --prefix=lisaSubTree/ -u lisa_branch\n    gitrm\n    git rm --cached -r lisaSubTree/.gitignore\n    git rm --cached -r lisaSubTree/*\n  fi\n}\ninitial\n\n\n\nOn Tue, Feb 7, 2017 at 7:44 PM, David Aguilar <davvid@gmail.com> wrote:\n> On Tue, Feb 07, 2017 at 08:59:06AM -0600, Samuel Lijin wrote:\n>> Have you tried using (without -s subtree) -X subtree=path/to/add/subtree/at?\n>>\n>> From the man page:\n>>\n>>           subtree[=<path>]\n>>                This option is a more advanced form of subtree\n>> strategy, where the strategy\n>>                makes a guess on how two trees must be shifted to match\n>> with each other when\n>>                merging. Instead, the specified path is prefixed (or\n>> stripped from the\n>>                beginning) to make the shape of two trees to match.\n>\n> I'm not 100% certain, but it's highly likely that the subtree=<prefix>\n> argument needs to include a trailing slash \"/\" in the prefix,\n> otherwise files will be named e.g. \"fooREADME\" instead of\n> \"foo/README\" when prefix=foo.\n>\n> These days I would steer users towards the \"git-subtree\" command in\n> contrib/ so that users don't need to deal with these details.  It\n> handles all of this stuff for you.\n>\n> https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt\n>\n> https://github.com/git/git/tree/master/contrib/subtree\n>\n> Updating the progit book to also mention git-subtree, in addition to the\n> low-level methods, would probably be a good user-centric change.\n> --\n> David\n"}]}