diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1d7c0296a91564e12eeff94008a4c9213d931b37..15de42af2ea2db5ad28c152a61e6e8423eb4b549 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -22,7 +22,7 @@ before_script:
   # Provision efficiently the local LFS cache before checkout
   - git lfs fetch origin $CI_COMMIT_SHA
   # Checkout the expected branch
-  - git checkout $CI_COMMIT_REF_NAME
+  - git checkout -f -q $CI_COMMIT_SHA
 
 after_script:
   - python3 CI/cdash_handler.py $CI_COMMIT_SHA $CI_PROJECT_ID $CI_PROJECT_DIR $K8S_SECRET_CDASH
@@ -46,7 +46,7 @@ fast-build:
   image: $BUILD_IMAGE_REGISTRY/otb-ubuntu-native-develop:latest
   before_script:
     - export GIT_LFS_SKIP_SMUDGE=1
-    - git checkout $CI_COMMIT_REF_NAME
+    - git checkout -f -q $CI_COMMIT_SHA
     - python3 CI/check_twin_pipelines.py
   script:
     - ctest -V -S CI/main_ci.cmake -DIMAGE_NAME:string=ubuntu-18.04-fast
@@ -82,7 +82,7 @@ ubuntu-llvm:
   before_script:
 # This override the previous before_script
     - export GIT_LFS_SKIP_SMUDGE=1
-    - git checkout $CI_COMMIT_REF_NAME
+    - git checkout -f -q $CI_COMMIT_SHA
     - export GIT_LFS_SKIP_SMUDGE=0
 # This is for debug, we are checking the owner of the ssh key
     - ssh -T git@gitlab.orfeo-toolbox.org