{"thread":{"id":"31693","subject":"Merging/joining two repos (repo2 should be a subdirectory of repo1)","startedAt":"2012-09-30T15:17:53Z","lastAt":"2012-10-03T12:52:03Z","messageCount":5,"participants":["Dirk Süsserott","David Aguilar"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"200214","messageId":"506862A1.8000508@dirk.my1.cc","threadId":"31693","inReplyTo":null,"subject":"Merging/joining two repos (repo2 should be a subdirectory of repo1)","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2012-09-30T15:17:53Z","receivedAt":"2012-09-30T15:17:53Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Hi!\n\nI have repo1 with ~4 years of history and another repo2 with ~1 year of\nhistory, both of which I don't want to loose. Now I want to join them so\nthat repo2 becomes a subdirectory whithin repo1, including all the\nhistory of repo2.\n\nA simple git-merge won't do because both repos have some same files (at\nleast e.g. .gitignore) in their root directories. Of course I could\nresolve the conflicts, but I don't want that.\n\nMy naive approach is \"move everything in $repo2 one directory below\" and\nthen \"merge $repo2 into $repo1\". Actually I wouldn' call that a \"merge\"\nbut an \"import\".\n\nI know of \"git filter-branch --subdirectory-filter foodir\" but that's\njust the opposite of what I need.\n\nIs there a nifty trick to get this? Or will I have to do \"git\nfilter-branch --tree-filter 'mkdir subdir && git mv * subdir' --all\" on\n$repo2 and then \"git merge $repo2\" in $repo1?\n\nThanks in advance\nDirk\n"},{"id":"200215","messageId":"50686605.6020909@dirk.my1.cc","threadId":"31693","inReplyTo":"1349018675-ner-5178@calvin","subject":"Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2012-09-30T15:32:21Z","receivedAt":"2012-09-30T15:32:21Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Am 30.09.2012 17:24 schrieb Tomas Carnecky:\n> On Sun, 30 Sep 2012 17:17:53 +0200, Dirk SÃŒsserott <newsletter@dirk.my1.cc> wrote:\n>> Hi!\n>>\n>> I have repo1 with ~4 years of history and another repo2 with ~1 year of\n>> history, both of which I don't want to loose. Now I want to join them so\n>> that repo2 becomes a subdirectory whithin repo1, including all the\n>> history of repo2.\n>>\n>> A simple git-merge won't do because both repos have some same files (at\n>> least e.g. .gitignore) in their root directories. Of course I could\n>> resolve the conflicts, but I don't want that.\n>>\n>> My naive approach is \"move everything in $repo2 one directory below\" and\n>> then \"merge $repo2 into $repo1\". Actually I wouldn' call that a \"merge\"\n>> but an \"import\".\n>>\n>> I know of \"git filter-branch --subdirectory-filter foodir\" but that's\n>> just the opposite of what I need.\n>>\n>> Is there a nifty trick to get this? Or will I have to do \"git\n>> filter-branch --tree-filter 'mkdir subdir && git mv * subdir' --all\" on\n>> $repo2 and then \"git merge $repo2\" in $repo1?\n> \n> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html\n> \n> \n\nWow! Thanks for that quick and *very* helpful answer! :-)\n"},{"id":"200216","messageId":"5068675C.8030706@dirk.my1.cc","threadId":"31693","inReplyTo":"269806202.iK1l2OpKr4@blacky","subject":"Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2012-09-30T15:38:04Z","receivedAt":"2012-09-30T15:38:04Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Am 30.09.2012 17:34 schrieb Sascha Cunz:\n>\n> You might want to have a look at the subtree merge strategy (see man\n> git-merge). Maybe that will already do what you want to.\n> \n>  \n> \n> Sascha\n> \n\nThank you as well. I wasn't aware of that option (or didn't figure out\nwhat it actually does).\n\nDirk\n"},{"id":"200223","messageId":"CAJDDKr4sXp7qqhzHN2_5sJeqaV23Z_uDiFsU_eFJrT5ApuWiTQ@mail.gmail.com","threadId":"31693","inReplyTo":"50686605.6020909@dirk.my1.cc","subject":"Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2012-09-30T20:44:11Z","receivedAt":"2012-09-30T20:44:11Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sun, Sep 30, 2012 at 8:32 AM, Dirk Süsserott <newsletter@dirk.my1.cc> wrote:\n> Am 30.09.2012 17:24 schrieb Tomas Carnecky:\n>> On Sun, 30 Sep 2012 17:17:53 +0200, Dirk SÃŒsserott <newsletter@dirk.my1.cc> wrote:\n>>> Hi!\n>>>\n>>> I have repo1 with ~4 years of history and another repo2 with ~1 year of\n>>> history, both of which I don't want to loose. Now I want to join them so\n>>> that repo2 becomes a subdirectory whithin repo1, including all the\n>>> history of repo2.\n>>>\n>>> A simple git-merge won't do because both repos have some same files (at\n>>> least e.g. .gitignore) in their root directories. Of course I could\n>>> resolve the conflicts, but I don't want that.\n>>>\n>>> My naive approach is \"move everything in $repo2 one directory below\" and\n>>> then \"merge $repo2 into $repo1\". Actually I wouldn' call that a \"merge\"\n>>> but an \"import\".\n>>>\n>>> I know of \"git filter-branch --subdirectory-filter foodir\" but that's\n>>> just the opposite of what I need.\n>>>\n>>> Is there a nifty trick to get this? Or will I have to do \"git\n>>> filter-branch --tree-filter 'mkdir subdir && git mv * subdir' --all\" on\n>>> $repo2 and then \"git merge $repo2\" in $repo1?\n>>\n>> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html\n>>\n>>\n>\n> Wow! Thanks for that quick and *very* helpful answer! :-)\n\nHi Dirk,\n\nYou should also take a look at contrib/subtree/ in the git source tree.\n\n\"git subtree\" does pretty much exactly what you're looking to do,\nand it is a bit more user-friendly than the plumbing commands.\n\nhttps://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt\n-- \nDavid\n"},{"id":"200409","messageId":"506C34F3.8090709@dirk.my1.cc","threadId":"31693","inReplyTo":"CAJDDKr4sXp7qqhzHN2_5sJeqaV23Z_uDiFsU_eFJrT5ApuWiTQ@mail.gmail.com","subject":"Re: Merging/joining two repos (repo2 should be a subdirectory of repo1)","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2012-10-03T12:52:03Z","receivedAt":"2012-10-03T12:52:03Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Am 30.09.2012 22:44 schrieb David Aguilar:\n> On Sun, Sep 30, 2012 at 8:32 AM, Dirk Süsserott <newsletter@dirk.my1.cc> wrote:\n>> Am 30.09.2012 17:24 schrieb Tomas Carnecky:\n>>> On Sun, 30 Sep 2012 17:17:53 +0200, Dirk SÃŒsserott <newsletter@dirk.my1.cc> wrote:\n>>>> Hi!\n>>>>\n>>>> I have repo1 with ~4 years of history and another repo2 with ~1 year of\n>>>> history, both of which I don't want to loose. Now I want to join them so\n>>>> that repo2 becomes a subdirectory whithin repo1, including all the\n>>>> history of repo2.\n>>>>\n>>>> A simple git-merge won't do because both repos have some same files (at\n>>>> least e.g. .gitignore) in their root directories. Of course I could\n>>>> resolve the conflicts, but I don't want that.\n>>>>\n>>>> My naive approach is \"move everything in $repo2 one directory below\" and\n>>>> then \"merge $repo2 into $repo1\". Actually I wouldn' call that a \"merge\"\n>>>> but an \"import\".\n>>>>\n>>>> I know of \"git filter-branch --subdirectory-filter foodir\" but that's\n>>>> just the opposite of what I need.\n>>>>\n>>>> Is there a nifty trick to get this? Or will I have to do \"git\n>>>> filter-branch --tree-filter 'mkdir subdir && git mv * subdir' --all\" on\n>>>> $repo2 and then \"git merge $repo2\" in $repo1?\n>>>\n>>> http://www.kernel.org/pub/software/scm/git/docs/howto/using-merge-subtree.html\n>>>\n>>>\n>>\n>> Wow! Thanks for that quick and *very* helpful answer! :-)\n> \n> Hi Dirk,\n> \n> You should also take a look at contrib/subtree/ in the git source tree.\n> \n> \"git subtree\" does pretty much exactly what you're looking to do,\n> and it is a bit more user-friendly than the plumbing commands.\n> \n> https://github.com/git/git/blob/master/contrib/subtree/git-subtree.txt\n> \n\nHi David,\n\nthanks for the pointer. I know of subtree and like it. But for my case\nI'll stick to the plumbing commands because I really want to *import*\n$repo2 into $repo1 and then delete $repo2. One shot.\n\n(Actually I re-wrote a part of our project just for fun and didn't do it\nin the main project's repo in a separate branch (as I normally do) but\nin a totaly separate repo. And now it turned out that my rewritten part\nis really cool and we want to include it in the main $repo1 and drop my\nprivate $repo2.)\n\nDirk\n"}]}