{"thread":{"id":"54880","subject":"How to integrate external repo into existing directory of a bigger repo (git subtree)?","startedAt":"2020-12-24T14:54:26Z","lastAt":"2020-12-25T10:13:54Z","messageCount":2,"participants":["Manuel Reimer"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"412998","messageId":"e30c1de9-9449-78d6-99eb-c3bbad673903@m-reimer.de","threadId":"54880","inReplyTo":null,"subject":"How to integrate external repo into existing directory of a bigger repo (git subtree)?","fromName":"Manuel Reimer","fromEmail":"mail+git@m-reimer.de","sentAt":"2020-12-24T14:53:13Z","receivedAt":"2020-12-24T14:54:26Z","isPatch":false,"sender":{"key":"mail+git@m-reimer.de","avatar":null},"body":"Hello,\n\nsome while ago (before I found out that \"git subtree\" exists), I've set \nup a big GIT repo consisting of several smaller modules. It was way more \nconvenient to maintain them all in one repository compared to having \neach in its own repository.\n\nAs I need a separate repository per module for technical reasons, I \nwrote a shellscript which temporarily checks out the external \nrepository, deletes all files, places the files from my big repo, \ncreates a generic commit with auto-generated commit message and then \npushes this to the server.\n\nSo what I have now is:\n\n- Big repo consisting of many small modules, each one in its own\n   directory with proper commit messages\n- Several external repositories with autogenerated commit messages\n\nWhat I want to do is porting this over to \"git subtree\" somehow, but:\n\n- I would prefer to not loose history in the \"big repo\"\n- I can't force-push to the small external repositories (blocked)\n\nIs there any chance to somehow \"restart\" the history of an existing \ndirectory in a way to reproduce the commits of the external repository \nso \"git subtree\" works as intended and I can \"git subtree push\" without \nrunning into the server side \"force push\" block? I know that \nreorganizing my whole big repo would do the trick as the subtree would \nbe added to a directory that never existed, but I would prefer to keep \nit organized the way it is.\n\nThanks in advance\n\nManuel\n"},{"id":"413013","messageId":"31b0d4a2-249f-ec18-8b7c-24b4a6165e7b@m-reimer.de","threadId":"54880","inReplyTo":"e30c1de9-9449-78d6-99eb-c3bbad673903@m-reimer.de","subject":"Re: How to integrate external repo into existing directory of a bigger repo (git subtree)?","fromName":"Manuel Reimer","fromEmail":"mail+git@m-reimer.de","sentAt":"2020-12-25T10:12:23Z","receivedAt":"2020-12-25T10:13:54Z","isPatch":false,"sender":{"key":"mail+git@m-reimer.de","avatar":null},"body":"On 24.12.20 15:53, Manuel Reimer wrote:\n> What I want to do is porting this over to \"git subtree\" somehow, but:\n> \n> - I would prefer to not loose history in the \"big repo\"\n> - I can't force-push to the small external repositories (blocked)\n\nJust for the record: I found a way to fix this properly.\n\nThe way to go is:\n\n- Create a new, empty, GIT repository (git init)\n- For some reason (bug?) \"git subtree\" fails on a completely new repo, \nso I had to add one initial commit (I used this to add a small helper \nshellscript that I want to use to simplify my \"git subtree\" work).\n- Now add all the wanted \"git subtrees\" from their existing \"external \nrepositories\" to the, so far, nearly empty repo. This creates a proper \n\"Add ...\" commit which seems to be the key to not break pushing to the \nexternal repo.\n- After adding all subtrees, pull from the \"big repo\", resolve conflicts \nand create a merge commit.\n\nAt this point I was able to \"git subtree push\" without needing to force. \nThis also transferred proper history for the subtrees to the individual \nexternal repos. Even the final push to my \"big repo\" worked without forcing.\n\nRegards,\n\nManuel\n"}]}