diff --git a/cook.sh b/cook.sh
index 5f8396fee783410574d42309af667776fc85a852..55e6cafb89582462ae9fad2867d7ac618e290881 100755
--- a/cook.sh
+++ b/cook.sh
@@ -119,6 +119,10 @@ function op {
                         git remote add upstream "$GIT_UPSTREAM"
                         git fetch upstream
                     fi
+                    if [ -n "$BRANCH" ]
+                    then
+                        git checkout "$BRANCH"
+                    fi
                     git pull
                     git submodule sync --recursive
                     git submodule update --init --recursive