Solution 2
If the above solution doesn't pull the latest, Try This:
git submodule update --init --recursive
None of the above answers worked for me.
This was the solution, from the parent directory run:
git submodule update --init;cd submodule-directory;git pull;cd ..;git add submodule-directory;
now you can git commit
and git push
A few of the other answers recommend merging/committing within the submodule's directory, which IMO can become a little messy.
Assuming the remote server is named origin
and we want the master
branch of the submodule(s), I tend to use:
git submodule foreach "git fetch && git reset --hard origin/master"
Note: This will perform a hard reset on each submodule -- if you don't want this, you can change --hard
to --soft
.
My project should use the 'latest' for the submodule. On Mac OSX 10.11, git version 2.7.1, I did not need to go 'into' my submodule folder in order to collect its commits. I merely did a regular
git pull --rebase
at the top level, and it correctly updated my submodule.
Andy's response worked for me by escaping $path:
git submodule foreach "(git checkout master; git pull; cd ..; git add \$path; git commit -m 'Submodule Sync')"