git submodule init not pulling latest commit
Git is doing exactly what it's supposed to be doing. git submodule update
will set your submodule to what the current commit in the parent repo specifies the submodule should be at. This way you can checkout another branch, older commit or tag, then run git submodule update
and the submodule will be set to what that reference expects so your entire solution will have it's dependencies satisfied.
What you need to do is:
cd mysubmoduledir
git fetch
git checkout master # or any other branch that you need the latest of
git merge origin/master
cd - # go back to the top repo
git status # should show that your submodule changed
git add mysubmoduledir
git commit -m "Updated my solution to use latest sub project."
a shorter version is:
cd mysubmoduledir
git pull # assumes you are already on the branch you need to be on
cd -
git commit -am "Updated submodule" # assumes you had no other modified files
The word "update" is not the best for this submodule command. It really means "point the submodule to the commit that the parent repo's commit expects".
Updating a submodule to a different commit (doesn't have to be the latest) requires you to cd into that directory, manipulate it like a regular git repo so the current commit is what you want, then go back out and commit this change on the top level repo.
Simply try below command after you have added your submodules.
for git v 1.8.x
git submodule update --init --recursive --remote
for v1.7.x:
git submodule update --init --recursive
or git pull --recurse-submodules
for v1.6.x
git submodule foreach git pull origin master
to check your git version.
git version