Updating a submodule
suggest changeA submodule references a specific commit in another repository. To check out the exact state that is referenced for all submodules, run
git submodule update --recursive
To move each submodule’s checkout onto the latest commit of a remote branch instead of the recorded gitlink:
git submodule foreach git pull <remote> <branch>
or use the default git pull arguments
git submodule foreach git pull
Note that this will just update your local working copy. Running git status will list the submodule directory as dirty if it changed because of this command. To update your repository to reference the new state instead, you have to commit the changes:
git add <submodule_directory>
git commit
Local commits in a submodule can conflict with that pull. --rebase replays those commits on top of the upstream instead of merging:
git submodule foreach git pull --rebase
To checkout the latest state of a specific submodule, you can use :
git submodule update --remote <submodule_directory>
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents