Fatal: .git/index: index file smaller than expected

When the stage of the pipeline started I received this error message

fatal: .git/index: index file smaller than expected
ERROR: Job failed: exit code 1

And the steps of the stage don’t run.

If I clone the repo, it works fine locally. I don’t have problems with the git index locally.

I am using GitLab locally.

  • GitLab Community Edition 11.7.5
  • gitlab-runner 12.7.1

Until now, this problem has happened only with this repo.

I tried with a local gitlab-runner and everything was fine.

I fixed it by changing in .gitlab-ci.yaml the GIT_STRATEGY to clone, because maybe the stage’s repo was corrupted. After the stage ran once I removed those lines to return to the default git strategy: fetch.

    GIT_STRATEGY: clone