Take the 2-minute tour ×

I had problems finding the answer to this so I am posting 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.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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.
share|improve this answer
add comment

If you want to update all your git submodules to HEAD of the remote repo just type

git submodule foreach git pull origin master

share|improve this answer
add comment

Your Answer


