I have:
- A main repository we call "MAIN"
- A submodule repository we call "SUB"
- In MAIN I add SUB as submodule
- Both repos are in master branch
Now what I need to do is creating a branch in both MAIN and SUB, such that when I'm on this branch on MAIN I can switch to a particular branch also in SUB. It seems to be impossible.
What I did is I created a branch (called branch_sub
) in SUB and pushed the new branch.
Now in MAIN I created another branch (called branch_main
) in MAIN and I modified both the .gitmodule and .git/config putting branch_sub
as "branch" field, such that the submodule should point at that particular branch. Pushed the commit in the branch of MAIN.
Now if I do git submodule update
, the SUB goes back to master branch and the original commit. Why? It's very stupid imo.
If I switch manually to branch_sub
, then do in MAIN git submodule update --remote
, the SUB stays on the correct commit, but in a detached HEAD
instead of the branch branch_sub
:(.
Any tip? Is it possible what I need to do? It seems very basic to me but git submodule doesn't seem to support it easily.