diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 436e9ec6c60248398b7c14d7a4843d81f9f421dc..bb94fc41ad152be6b71ad48ada350bd61d9adad4 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -319,12 +319,11 @@ migration paths:
     - master@gitlab/gitlabhq
     - master@gitlab/gitlab-ee
   script:
-    - git checkout HEAD .
-    - git fetch --tags
-    - git checkout v8.5.9
+    - git fetch origin v8.5.9
+    - git checkout -f FETCH_HEAD
     - cp config/resque.yml.example config/resque.yml
     - sed -i 's/localhost/redis/g' config/resque.yml
-    - bundle install --without postgres production --jobs $(nproc) "${FLAGS[@]}" --retry=3
+    - bundle install --without postgres production --jobs $(nproc) ${FLAGS[@]} --retry=3
     - rake db:drop db:create db:schema:load db:seed_fu
     - git checkout $CI_BUILD_REF
     - source scripts/prepare_build.sh