I have this situation with git version 2.8.0.windows.1
.
I have one "release" branch of the main project and I push there everytime I've a new release.
This project has a submodule that is developed in parallel, so I expect many commits there.
Project Master branch and Submodule Master branches goes ahead (almost) in parallel.
Master Commit 1 => Master Commit 2 => Master Commit 3 => Master Commit 4
Submodule Commit 1 => Submodule Commit 2 => Submodule Commit 3 => Submodule Commit 4
In this case Master Commit 4 is aligned with Submodule Commit 4.
The issue arises when someone tries to get the release branch too late.
So if I push the release branch at Master Commit 1 and someone pull release branch when we are at Master Commit 4 we have a misalignment (because release is related to Master Commit 1, while now we are on Submodule Commit 4).
The solution I see is to coerce somehow Submodule Commit 1 to release branch, but I don't know how yet.
I know that a great solution would be just to add a branch or tag on the submodule as explained here.
But I've no authority over the submodule repository, so it won't be easy for me to set branches or tags there.
Are there any workarounds to coerce a specific submodule commit on my release branch and not just a submodule branch/tag?
This is how submodules work anyway so I don't understand your problem. Let's me try to enhance or fix your workflow. You need every commit in the release
branch points to the corresponding commit in the submodule, right? This is easy: before making commits in the release
branch update the submodule, checkout the correct commit in the submodule and commit the change in superproject:
# In the superproject
git checkout release
cd subdir # into the submodule
git checkout master # reconcile detached HEAD
git pull origin master # update the submodule
git checkout some-sha1 # if you don't want the latest commit in master
cd .. # back into superproject
git add subdir
git commit -m "Update submodule"
Now everyone who git clone --recursive
the superproject gets the submodule pointed to the correct commit for every commit in the branch release
.