How to stick a submodule to a fix a tag?

2019-06-01 19:18发布

问题:

Assume we have two modules super and minor. Module super depends on version v1.0.3 of module minor, whereas v1.0.3 is an annotated tag on minor:

        v1.0.3
super <-------- minor

Module minor is kind of "private", i.e. only a very small group of developers has write access and others only have read access. Module super is public.

Now I would like to model the dependency of module super to module minor utilizing Git submodules. Unfortunately I can't figure out how to fix the dependency to v1.0.3.

In addition, I would also like --- some time in future --- to fix the dependency to another version.

In all cases I would like to have that ... all developers "automatically" retrieve the module minor in the correct version. ... all developers --- but the afore mentioned small group --- are not allowed to modify this dependency (whereas this is a minor issue)

Any ideas?

Cheers, /nm

回答1:

First, submodules reference commits (SHA1), so the simplest way to memorize the right SHA1 is to go in your submodule and simply git checkout v1.0.3, then go back to your parent repo, commit and push that new state: since a tag is associated to a commit, you will push the fact that your submodule is associated with that tag.
The same process can be repeated when you want to adjust the tag of that same submodule.

Regarding the right to modify that submodule, one way to control that is to add an authorization framework on your Git server: gitolite.