Pull latest changes for all git submodules

Git submodules allow you to include a Git repository within another Git repository. This can be useful for organizing and sharing dependencies or code between multiple projects.

 

To update all submodules to their latest changes, you can use the following steps:

 

  • Change to the root directory of your Git repository:
cd <repo_root>

 

  • Use the following command to update the submodule references to the latest commit in each submodule's remote repository:
git submodule update --remote

 

  • Commit the changes to the submodule references in your main repository:
git commit -m "Update submodules"

 

  • (Optional) If the submodules have been updated to a different commit than what you currently have checked out in your local repository, you can use the following command to checkout the latest version of each submodule:
git submodule foreach git checkout HEAD

 

After these steps, your submodules will be updated to the latest changes in their respective remote repositories. Note that you may need to repeat these steps if changes are made to the submodules in the future.

 

There are some alternate way to pull all latest  in git sub modules
 
If it's the first time you check-out a repo you need to use --init first:

git submodule update --init --recursive

 

For git 1.8.2 or above, the option --remote was added to support updating to latest tips of remote branches:

git submodule update --recursive --remote

Tags:

git

Share:

Related posts