views:

65

answers:

1

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.

+2  A: 

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.
cmyers