GitLab CI checks out commit as detached HEAD

Summary

Using GitLab CI the Getting source from Git repository step announces e.g.

Checking out 10308d73 as main...

The correct git hash is used but checked out as detached HEAD rather than main (or what ever the active branch might be).

Steps to reproduce

  • My project's git strategy is set to git fetch (which may or may not be relevant)
  • Set up a project with GitLab CI
  • Run a pipeline with a job that does e.g. git status

What is the current bug behavior?

git status outputs e.g. HEAD detached at 10308d7

What is the expected correct behavior?

git statusoutputs e.g. On branch main.

Edited by 🤖 GitLab Bot 🤖