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