I had problems finding the answer to this so I am posting开发者_Python百科 it for posterity.
The situation is, you have a git repo with a submodule (similar to an svn external). You want to update that reference to point to a different commit in the external repository. You might think 'git submodule sync' or 'git submodule update' would do that - you'd be wrong.
The steps are:
- cd to the actual directory the submodule is in.
- run 'git pull origin' or whatever you want to do to set it to a new commit.
- cd out of that directory (presumably to the repository root) and run "git status" - you will see that the directory is changed. If you do a diff you will see something like this:
diff --git a/default/bin/hdvcs b/default/bin/hdvcs index bbd3f56..7c9394c 160000 --- a/default/bin/hdvcs +++ b/default/bin/hdvcs @@ -1 +1 @@ -Subproject commit bbd3f56898054e533e81b52b90b94155841b40a8 +Subproject commit 7c9394c8520e41a704e6658360064758b20a3dfc
- commit this change.
If you want to update all your git submodules to HEAD of the remote repo just type
git submodule foreach git pull origin master
精彩评论