Single file as Git submodule

后端 未结 3 709
误落风尘
误落风尘 2020-12-15 19:44

I\'m trying to ascertain best-practices for shared code amongst Git repositories.

So far, I\'ve obviously come across submodules which seem like they - almost - fit

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-15 20:07

    A submodule is a git repository, with its own .git directory, so it must be contained in a directory. I don't believe there's any way to easily get around that. You're going to have to package your stuff into a directory somehow - and if core.php goes with the stuff in core, it makes complete sense for them to be together in a submodule repo!

    rmk's answer, suggesting you do this all in one repo, using core and core.php as a starting point is another reasonable one. You should make your decision based on your anticipated workflow. A submodule will be good if you plan on modifying the core* content separately from the projects which use it; you can then update the submodules in the various projects that use it. A baseline repository will be good if you want to modify the core* content to suit a specific project; you can then pull from the baseline repo to get updates, merging them with the changes you've made in the project repo.

提交回复
热议问题