I have a repository with one submodule.
But I would like the commits made in the submodule to be informed in my tag used in the main repository.
Is it possible to perform this procedure?
Note: I use the Jenkins tool for build, deploy and it has a stage for creating tags.
I have been trying the commands below:
This command doesn't put the commits on tag
git submodule update --init --recursive --remote
This command return the message: Entering 'SUBMODULE/FOLDER'
git submodule foreach --recursive 'git fetch --tags --force'
CodePudding user response:
All you have to do and create commits in your submodule.
The changed state (meaning the fact the submodule checked out in your main repository is at a different root tree SHA1) will be detected.
That's because the commit that was checked out inside that submodule directory has changed.
When you git add path/to/submodule
and git commit
a change to a submodule in the parent project, it records the hash that submodule is checked out to. If you then commit that change, it commits the "submodule state".
Don't use submodule update
with --remote
!
Use git submodule update --init --recursive
instead (in the parent project). This will checkout all submodules to the state saved in the parent project's commit.
Using --remote
destroys any guarantee of submodule state.