Is anyone really using git super/subprojects?

后端 未结 3 1314
无人及你
无人及你 2020-12-25 13:28

Is anyone using the new git super/subproject feature in real projects? How well does it work? For instance, I understand that if I push to a subproject I have to manually ca

3条回答
  •  抹茶落季
    2020-12-25 13:59

    By using submodule, you are defining in your Git workspace (meaning your "super-project" Git repository) a configuration.
    By "configuration", I mean "the list of tags or SHA-1 node necessary to work in your workspace".
    (and by work, I mean whatever "development effort" you are doing within your workspace: classic compilation, or patch, or merge, or deployment, or...).
    That is the case when your are cloning a super-project and "git update" your submodules: you are checkouting the exact repos SHA1 which were previously committed in the super-project (recorded as gitlink in the index).

    The other mode is when you are working on your super-project and on one or more submodules.
    That means, for a given submodules, you have checked out a specific branch (you are no longer using a detached HEAD for the content of that submodules, but rather a pointer to the tip of a branch).
    Then, "pushing a submodule" means updating a distant repository containing that sub-module (and only that one).

    The actual trick in that last scenario (which could deserve a hook of you want one) is when you are pushing the super-project: you need to be sure to have pushed all your sub-modules first.

    From the submodule tutorial:

    Always publish the submodule change before publishing the change to the superproject that references it. If you forget to publish the submodule change, others won't be able to clone the repository (of the super-project)

    Don't forget you can configure a submodule to follow a branch.

提交回复
热议问题