{"thread":{"id":"47826","subject":"\"git submodule\" vs \"git subtree\" vs \"repo\" vs \"git subdir\" ... ?","startedAt":"2018-02-13T13:06:31Z","lastAt":"2018-02-13T18:25:40Z","messageCount":3,"participants":["Robert P. J. Day","Nicolas Morey-Chaisemartin","Stefan Beller"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"339194","messageId":"alpine.LFD.2.21.1802130746360.16738@localhost.localdomain","threadId":"47826","inReplyTo":null,"subject":"\"git submodule\" vs \"git subtree\" vs \"repo\" vs \"git subdir\" ... ?","fromName":"Robert P. J. Day","fromEmail":"rpjday@crashcourse.ca","sentAt":"2018-02-13T13:06:23Z","receivedAt":"2018-02-13T13:06:31Z","isPatch":false,"sender":{"key":"rpjday@crashcourse.ca","avatar":"https://avatars.githubusercontent.com/u/226084077?v=4"},"body":"\n  looking for general opinions ... i am (frighteningly :-) teaching a\ngit course later this week, and one of the topics on the list is git\nsubmodules, which was specifically requested by the client as their\nidea of how to start incorporating child repos in new projects.\n\n  however, given the number of articles written about the drawbacks\nwith submodules, i wanted to throw in a section about \"git subtree\" as\nwell, even though (as discussed earlier) there is some minor dispute\nas to whether \"git subtree\" is part of \"core\" git, but i'm not going\nto let that stop me.\n\n  going even beyond that, there is also google's \"repo\" command, which\ni seem to see more and more often, like here for automotive grade\nlinux:\n\n  https://wiki.automotivelinux.org/agl-distro/source-code\n\nand it would be a shame to at least not mention that as yet another\npossibility.\n\n  and then there are unofficial, hand-rolled solutions, like\n\"git-subdir\":\n\n  https://github.com/andreyvit/git-subdir\n\ngiven that the client does not appear to be wedded to any particular\nsolution yet, i'm open to recommendations or pointers to online\ncomparisons that i'll collect and post on a single wiki page, and they\ncan peruse the comparisons at their leisure.\n\n  so ... thoughts? no need to be verbose, just links to decent online\ndiscussions/comparisons would be massively useful.\n\nrday\n\np.s. oh, pointers to well-designed usage of any of the above would be\nhandy as well. as i mentioned, for \"repo\", there's AGL. for\nsubmodules, i might use boost:\n\n  https://github.com/boostorg/boost/wiki/Getting-Started\n\nand so on. thank you kindly.\n"},{"id":"339198","messageId":"338901fc-6dc8-2684-c116-393e603f85e9@suse.de","threadId":"47826","inReplyTo":"alpine.LFD.2.21.1802130746360.16738@localhost.localdomain","subject":"Re: \"git submodule\" vs \"git subtree\" vs \"repo\" vs \"git subdir\" ... ?","fromName":"Nicolas Morey-Chaisemartin","fromEmail":"nmoreychaisemartin@suse.de","sentAt":"2018-02-13T14:23:49Z","receivedAt":"2018-02-13T14:24:00Z","isPatch":false,"sender":{"key":"nmoreychaisemartin@suse.de","avatar":"https://gravatar.com/avatar/5546322ccb9067f56b6939d9d5c758a40cab5b978b1379fd6ec8ab9b8a6a12b1?d=mp&s=160"},"body":"\n\nLe 13/02/2018 à 14:06, Robert P. J. Day a écrit :\n>   looking for general opinions ... i am (frighteningly :-) teaching a\n> git course later this week, and one of the topics on the list is git\n> submodules, which was specifically requested by the client as their\n> idea of how to start incorporating child repos in new projects.\n>\n>   however, given the number of articles written about the drawbacks\n> with submodules, i wanted to throw in a section about \"git subtree\" as\n> well, even though (as discussed earlier) there is some minor dispute\n> as to whether \"git subtree\" is part of \"core\" git, but i'm not going\n> to let that stop me.\n\nI've dealt with a large number of submodules and subtrees in the last years so here are my 2 cents.\nThe first question to ask is the most important one:\nDo the repos really need to be split at all.\n\nIn a previous life, we started with one repo per \"small projects\", each containing a couple of binaries or libs.\nEverything was put together through submodules.\nAfter way too long to admit, we realized that it was just not worth it. We had to deal with so many corner cases in CI and other things for a no real gain.\nThe reality is git works perfectly with bigger projects and smart enough that people working on two different \"subprojects\" don't create any conflict.\nSo we started merging a lot of it back into the main repo and that was it.\n\nI see some advantages submodules have other subtrees:\n- It's slightly easier to in a subproject when using submodule than with subtree (at least for git newcomers).\nOnce you made sure your submodule is on a branch, you just go into it and work in a standard git.\nWhen using subtree, you have to know you're in a subtree and to your subtree push/pull to resync with someone working directly in the subproject.\nAt the time conflict in subtrees were sometimes a bit weird and created history full of merge.\n\n- submodules are great when working with huge subrepo.\nWe have a repository than had among its submodule: linux, gcc, gdb, glibc.\nThis means a real lot of code/files and commits.\nSubtree would work but you'd endup with a humongous repo and as expected everything is slowed down.\n\n- submodules work well when you are moving between versions and branches of a subproject.\nLet me clarify with an example:\nWe had a repo that had ffmpeg as a submodule with a large patch series from us.\nWe would regularly create a new branch in the subrepo with all our patches on top of a new ffmpeg upstream release.\nAnd simply point the top project to this SHA1. And it worked great.\nI wouldn't risk doing that kind of things with subtree. I may be wrong here (I haven't tried it to be honest) the the push/pull approach doesn't seem to fit\n the idea of moving from a SHA1 to a seemingly unrelated one.\n\nNow that I'm working with reasonable repo sizes again, and linear history, I mostly stick with subtrees.\n\nNicolas\n"},{"id":"339212","messageId":"CAGZ79kYubKmmpg_aka=P0FMjQSqrYQaerq3=awwGRfW_H8H+Vg@mail.gmail.com","threadId":"47826","inReplyTo":"alpine.LFD.2.21.1802130746360.16738@localhost.localdomain","subject":"Re: \"git submodule\" vs \"git subtree\" vs \"repo\" vs \"git subdir\" ... ?","fromName":"Stefan Beller","fromEmail":"sbeller@google.com","sentAt":"2018-02-13T18:25:32Z","receivedAt":"2018-02-13T18:25:40Z","isPatch":false,"sender":{"key":"stefanbeller@gmail.com","avatar":"https://avatars.githubusercontent.com/u/455868?v=4"},"body":"On Tue, Feb 13, 2018 at 5:06 AM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:\n>\n>   looking for general opinions ... i am (frighteningly :-) teaching a\n> git course later this week, and one of the topics on the list is git\n> submodules, which was specifically requested by the client as their\n> idea of how to start incorporating child repos in new projects.\n>\n>   however, given the number of articles written about the drawbacks\n> with submodules, i wanted to throw in a section about \"git subtree\" as\n> well, even though (as discussed earlier) there is some minor dispute\n> as to whether \"git subtree\" is part of \"core\" git, but i'm not going\n> to let that stop me.\n>\n>   going even beyond that, there is also google's \"repo\" command, which\n> i seem to see more and more often, like here for automotive grade\n> linux:\n>\n>   https://wiki.automotivelinux.org/agl-distro/source-code\n>\n> and it would be a shame to at least not mention that as yet another\n> possibility.\n\nPlease note that Google would prefer to get rid of the repo tool.\n(It was made as a stop gap solution until submodules are good enough,\ni.e. have comparable UX compared to repo. But as you know stop gap\nsolutions hold up for quite a long time reliably. :) repo has issues by itself,\nfundamental issues such as the data model, as well as minor things like\ncomplete lack of tests)\n\n>   and then there are unofficial, hand-rolled solutions, like\n> \"git-subdir\":\n>\n>   https://github.com/andreyvit/git-subdir\n>\n> given that the client does not appear to be wedded to any particular\n> solution yet, i'm open to recommendations or pointers to online\n> comparisons that i'll collect and post on a single wiki page, and they\n> can peruse the comparisons at their leisure.\n\nThere are a couple of these. I came across these recently\nhttp://gitslave.sourceforge.net/\nhttps://github.com/ingydotnet/git-subrepo\n\n>   so ... thoughts? no need to be verbose, just links to decent online\n> discussions/comparisons would be massively useful.\n>\n> rday\n>\n> p.s. oh, pointers to well-designed usage of any of the above would be\n> handy as well. as i mentioned, for \"repo\", there's AGL. for\n> submodules, i might use boost:\n\nIf your copy of Git is recent, look at the man pages for submodules\nsuch as d48034551a (submodules: overhaul documentation, 2017-06-22)\nor 4f73a7f124 (Doc/gitsubmodules: make some changes to improve\nreadability and syntax, 2018-01-14)\n\n>   https://github.com/boostorg/boost/wiki/Getting-Started\n>\n> and so on. thank you kindly.\n\nStefan\n"}]}