Git submodule - How to keep the submodule updated when pulling from the main repo

Viewed 3725

We have the main git repository and one single git submodule. For this question, the main repository does only have a master branch, and the submodule does have two branches - X and Y.

Let's say Coder A just switched to submodule branch X and applied some small changes.
Coder B it's on submodule branch Y.

Now A pushes to the remote and B pulls - then it does not seem like B's active submodule commit (on their local machine) gets automatically changed to the commit that A pushed on branch X, even though A actively committed the changed submodule commit.
Instead for B, their version on branch Y stays active.

If B does now manually pull from the repository and set the branch to X, everything works again.

How can we achieve that submodule changes / active commits get automatically synced when pulling from the main repository?

We're using Source Tree as Git GUI if that makes any explanations easier.

1 Answers
Related