Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update all submodules?

Tags:

git

How to update submodules, and with which Git client?

I am currently working with GitKraken.. but it is not friendly to work because you have to open each submodules (one by one) to update 'em and go back git main module and update all submodules.
We are using this workflow (commit, pull and push) for each submodule: is that right?

A Google search did not yield any conclusive answer.

like image 393
sealabr Avatar asked Nov 22 '17 19:11

sealabr


People also ask

How do I download all submodules in git?

Pulling with submodules. Once you have set up the submodules you can update the repository with fetch/pull like you would normally do. To pull everything including the submodules, use the --recurse-submodules and the --remote parameter in the git pull command .

Does git fetch update submodules?

If you want to check for new work in a submodule, you can go into the directory and run git fetch and git merge the upstream branch to update the local code. Now if you go back into the main project and run git diff --submodule you can see that the submodule was updated and get a list of commits that were added to it.

How do you fix a dirty submodule?

You can fix it by: either committing or undoing the changes/evolutions within each of your submodules, before going back to the parent repo (where the diff shouldn't report "dirty" files anymore). To undo all changes to your submodule just cd into the root directory of your submodule and do git checkout .


1 Answers

As I illustrated here, the Git command line remains the best (and most complete) option

git config pull.rebase true
git config rebase.autoStash true
git config fetch.recurseSubmodules true

Then, a simple git pull would be enough to update your current branch as well as all the submodules.
Make sure your submodules are tracking a branch, and I have detailed in "", you can do a git submodule update --remote --merge at any time.
You have also the command git submodule foreach to execute commands inside submodules.

like image 127
VonC Avatar answered Sep 23 '22 10:09

VonC