Skip to content

GIT_STRATEGY: empty fails with "fatal: not a git repository (or any of the parent directories): .git"

Summary

A simple job using GIT_STRATEGY: empty fails with the error: fatal: not a git repository (or any of the parent directories): .git

The same job without GIT_STRATEGY set succeeds.

Steps to reproduce

Here's the project demonstrating this issue: https://gitlab.com/candrews/test-git_strategy/

.gitlab-ci.yml
---
test:
  variables:
    GIT_STRATEGY: empty
  image: alpine
  script:
    - |
      # shellcheck shell=sh
      set -eu
      echo 'This job should succeed'
      exit 0

Actual behavior

The job fails:

Running with gitlab-runner 17.7.0~pre.103.g896916a8 (896916a8)
  on green-4.saas-linux-small-amd64.runners-manager.gitlab.com/default ntHFEtyX, system ID: s_8990de21c550
Preparing the "docker+machine" executor 00:06
Using Docker executor with image alpine ...
Pulling docker image alpine ...
Using docker image sha256:aded1e1a5b3705116fa0a92ba074a5e0b0031647d9c315983ccba2ee5428ec8b for alpine with digest alpine@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c ...
Preparing environment 00:00
Running on runner-nthfetyx-project-67908214-concurrent-0 via runner-nthfetyx-s-l-s-amd64-1741702826-6ba0e978...
Getting source from Git repository 00:01
Skipping Git repository setup and creating an empty build directory
Skipping Git checkout
Skipping Git submodules setup
$ git remote set-url origin "${CI_REPOSITORY_URL}"
fatal: not a git repository (or any of the parent directories): .git
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 1

Expected behavior

The job should succeed.

Relevant logs and/or screenshots

job log
Running with gitlab-runner 17.7.0~pre.103.g896916a8 (896916a8)
  on green-4.saas-linux-small-amd64.runners-manager.gitlab.com/default ntHFEtyX, system ID: s_8990de21c550
Preparing the "docker+machine" executor 00:06
Using Docker executor with image alpine ...
Pulling docker image alpine ...
Using docker image sha256:aded1e1a5b3705116fa0a92ba074a5e0b0031647d9c315983ccba2ee5428ec8b for alpine with digest alpine@sha256:a8560b36e8b8210634f77d9f7f9efd7ffa463e380b75e2e74aff4511df3ef88c ...
Preparing environment 00:00
Running on runner-nthfetyx-project-67908214-concurrent-0 via runner-nthfetyx-s-l-s-amd64-1741702826-6ba0e978...
Getting source from Git repository 00:01
Skipping Git repository setup and creating an empty build directory
Skipping Git checkout
Skipping Git submodules setup
$ git remote set-url origin "${CI_REPOSITORY_URL}"
fatal: not a git repository (or any of the parent directories): .git
Cleaning up project directory and file based variables 00:00
ERROR: Job failed: exit code 1

Environment description

gitlab.com

Used GitLab Runner version

gitlab.com

Possible fixes

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information