Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to update one submodule git?

Tags:

git

github

I have a couple of submodules and I only want to update one of them.

I think this command updates all of them in .gitmodules

git submodule update --init --recursive --remote

I just want one of the modules updated though.

like image 631
Thomas Mccaffery Avatar asked Jul 22 '17 06:07

Thomas Mccaffery


People also ask

How do I update a specific submodule?

By adding the submodule. <name>. update config setting, you ensure that the selective clone of the submodule will be followed by an update, only for that submodule.

How do I update a submodule in git recursive?

If you already cloned the project and forgot --recurse-submodules , you can combine the git submodule init and git submodule update steps by running git submodule update --init . To also initialize, fetch and checkout any nested submodules, you can use the foolproof git submodule update --init --recursive .

Can I make changes to a submodule?

If you want to make a change within a submodule, you should first check out a branch, make your changes, publish the change within the submodule, and then update the superproject to reference the new commit.

How do I change a submodule to a specific commit?

Use the git submodule update command to set the submodules to the commit specified by the main repository. This means that if you pull in new changes into the submodules, you need to create a new commit in your main repository in order to track the updates of the nested submodules.


Video Answer


1 Answers

The git submodule update command takes a path as a parameter.

Use the path of the submodule you want to update, as said path is recorded in your .gitmodules.

git submodule update --init --remote a/submodule/path

Make sure your submodule follows a branch first.

For a manual update, you also can go into the submodule folder, and do a git checkout aBranch/git pull yourself. Then go back to the parent repo, add and commit the new gitlink SHA1 for that submodule.

like image 51
VonC Avatar answered Sep 29 '22 08:09

VonC