diff --git a/update-repository b/update-repository
index 59fb769421391b057da0ea64c21d785faff8a3f8..8d1aa9528e7c0dc4f24a80833ae4371fbace1bad 100755
--- a/update-repository
+++ b/update-repository
@@ -3,4 +3,4 @@
 # This script updates the repository and its subrepositories, recursively.
 
 git submodule update --init
-git submodule foreach '[ "$path" = "moogli" ] && branch=geometry || branch=master; git pull origin $branch' 
+git submodule foreach '[ "$path" = "moogli" ] && branch=geometry || branch=master; git pull origin $branch; git checkout $branch'