diff --git a/tools/dist.sh b/tools/dist.sh
index b2b030e148f4b905db8c327ce46f002e7379b17b..b24475cc0f4f622c026d2edae2bc9333fdc7d4d2 100755
--- a/tools/dist.sh
+++ b/tools/dist.sh
@@ -19,7 +19,7 @@ if [ ! -z "${CI}" ]; then
         # Otherwise, let normal version machinery run, but fetch all changes
         # and check out the correct branch. Otherwise we'll get weird version
         # strings.
-        git fetch origin "$CI_COMMIT_REF_NAME"
+        git fetch --unshallow origin "$CI_COMMIT_REF_NAME"
         git checkout "$CI_COMMIT_REF_NAME"
         version="$(python3 components/st3m/host-tools/version.py)"
     fi