{"thread":{"id":"53563","subject":"git submodule question","startedAt":"2020-05-27T15:20:35Z","lastAt":"2020-06-10T06:02:25Z","messageCount":2,"participants":["Laura Smith","Stefan Moch"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"398637","messageId":"Wri_F6OxTiG7HZNvyVdFwGp7qrTWqC7Oipu214kLQ8gGMhna7SU6AXdm_m8tkDaPlMKtXGXc84TSACkN0tigR9satiLkrXn23bfM331g09U=@protonmail.ch","threadId":"53563","inReplyTo":null,"subject":"git submodule question","fromName":"Laura Smith","fromEmail":"n5d9xq3ti233xiyif2vp@protonmail.ch","sentAt":"2020-05-27T15:01:21Z","receivedAt":"2020-05-27T15:20:35Z","isPatch":false,"sender":{"key":"n5d9xq3ti233xiyif2vp@protonmail.ch","avatar":null},"body":"Hi,\n\nI'm using git submodule to pull some third-party config templates into my git tree, using the following:\n\ngit fetch  foobar-github master\ngit subtree pull --prefix software/files/perimiter_mail/foobar-github foobar-github master --squash\n\nNow, the question is, when the upstream makes a new commit can I force pull that commit and make git overwrite any changes I've made in the subtree.\n\nAt the moment I get bitter complaints from git, e.g. :\nCONFLICT (content): Merge conflict in....\nAutomatic merge failed; fix conflicts and then commit the result.\n\nBasically, I want to make myslef an update script that force-pulls the latest upstream repo and then the script will take care of making the necessary modifications (the upstream puts placeholders in their repo, so my script would take care of replacing the placeholders with the real values so that everything works again)\n\nThanks !\n"},{"id":"399389","messageId":"02d1bf3e-0fc8-a02b-68d0-2982dc209c55@mail.de","threadId":"53563","inReplyTo":"Wri_F6OxTiG7HZNvyVdFwGp7qrTWqC7Oipu214kLQ8gGMhna7SU6AXdm_m8tkDaPlMKtXGXc84TSACkN0tigR9satiLkrXn23bfM331g09U=@protonmail.ch","subject":"Re: git submodule question","fromName":"Stefan Moch","fromEmail":"stefanmoch@mail.de","sentAt":"2020-06-10T06:02:08Z","receivedAt":"2020-06-10T06:02:25Z","isPatch":false,"sender":{"key":"stefanmoch@mail.de","avatar":null},"body":"Laura Smith wrote:\n> I'm using git submodule to pull some third-party config templates into my git tree, using the following:\n>\n> git fetch  foobar-github master\n> git subtree pull --prefix software/files/perimiter_mail/foobar-github foobar-github master --squash\n>\n> Now, the question is, when the upstream makes a new commit can I force pull that commit and make git overwrite any changes I've made in the subtree.\n\n(Side node: there is `git submodule` as well as `git subtree`, they\nare similar in their goals, but work quite differently.)\n\nI have not used subtree much, but from a first glance it seems to me\none would have to either (a) revert the own changes or (b) commit\nchecked out files from the last upstream version again prior to the\n`git subtree pull` to get git subtree merge/pull deliver exactly the\nfiles from new version the upstream repository into the subtree.\nThat would lead at least to a untidy history with a back and forth\nof placeholders and replacements and scripting it could also be a\nbit cumbersome.\n\nHowever, /not/ changing the template files would also be a\npossibility to generate your files:\n\n> At the moment I get bitter complaints from git, e.g. :\n> CONFLICT (content): Merge conflict in....\n> Automatic merge failed; fix conflicts and then commit the result.\n>\n> Basically, I want to make myslef an update script that force-pulls the latest upstream repo and then the script will take care of making the necessary modifications (the upstream puts placeholders in their repo, so my script would take care of replacing the placeholders with the real values so that everything works again)\n\nIf you are going to write a script that replaces the placeholders in\nthe config templates, you could as well leave the whole subtree /as\nit is/ in upstream (i.e. without replacement of placeholders) and\nonly use `git subtree pull` go get the upstream changes – without\nconflicts from now on. (Or maybe only make structural changes to the\ntemplates itself (e.g. added/removed blocks of text), if needed at\nall. That should probably lead to fewer conflicts than changing the\nplaceholders in place.)\n\nYou can then use your script to generate /another/ file (with\nreplacement of placeholders) from each config template as part of\nyour build process or whatever is run from this repository. The\ngenerated files may or may not be added to the repository (outside\nof the subtree). If their content is reproducible (with templates,\nscript, and replacements), it is not necessarily needed to add them,\njust regenerate them if needed or if their corresponding template\nchanged.\n\n\n"}]}