LGTM build fails at Checkout for C project with "You are in 'detached HEAD' state."

I have some repos in C language that I would like to perform analysis on LGTM and for each of them the build fails at Checkout with:

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b <new-branch-name>