diff --git a/build-and-benchmark-py-project.sh b/build-and-benchmark-py-project.sh
index a6ed63525c240b7acf66d38f057fd036ae4385e0..933f73a00ea7a72dabc46ac0f044cf3e6cfa3a4d 100644
--- a/build-and-benchmark-py-project.sh
+++ b/build-and-benchmark-py-project.sh
@@ -30,6 +30,7 @@ if [[ ! -z "$CI" ]]; then
   rm -rf .asv/env
   # Fetch the master branch as git repository in gitlab ci env doesn't have it.
   git fetch origin master
+  git checkout -t origin/master
 fi
 
 if [[ ! -f ~/.asv-machine.json ]]; then