I have a project named sample which have 2 submodules sampleA and sampleB. I also have another git repo named Example which also refers to same submodule sampleA and sampleB. When I change something in submodule sampleA from the project Example and pushed into remote. Now the submodule sampleA from the project sample pointing to old commit of the submodule sampleA. I want all of these submodules to point to latest commit.

my .gitmodules:

[submodule "sampleA"]
    path = sampleA
    url = https://gitlab....sampleA.git
    branch = alpha
[submodule "sampleB"]
    path = sampleB
    url = https://gitlab...sampleB.git
    branch = alpha

I have many branches. I need to point the submodule to latest commit of corresponding branch in every project. When i go throw the internet for the solution found solutions similar to this:

Update Git submodule to latest commit on origin

that is to update manually through command ,but i want to do this automatically for remote. otherwise i need to push this to all of my projects. How can i do this?

2 Replies 2

Open-ended questions are questions nonetheless. I don't see a question here. Neither in title, nor in body. (Edit: I see your "How can I do this" addition. Minimal, but technically a question, okay.)

Running git submodule update --remote (or equivalent commands) is the only way. Even worse, after updating submodules you should go back to the superproject repo and commit changes in submodules. You can semiautomate this using scripts, running from cron or a CI pipeline but said commands must be run somehow, no way around that.

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.