Skip to content

warning: remote HEAD refers to nonexistent ref, unable to checkout.

Summary

When creating a project with a develop branch but no master branch, the .git/HEAD still refers to master.

Steps to reproduce

  1. Create a project in gitlab but don't initialize it with a README.md
  2. Clone the project
  3. Then, create the develop branch, add a file, then push :
cd <project_dir>
git checkout -b develop
touch test.md
git add test.md
git commit -m "test.md"
git push -u origin develop
  1. Clone again the project in another directory, you will see the warning (last line) :
Cloning into 'test-project-100'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.

Relevant logs and/or screenshots

In the clone project, you can see the file .git/HEAD

ref: refs/heads/master

If you logged into the gitlab server, on each gitaly nodes, we can see :

cat /home/git/repositories/@hashed/2c/7d/2c7d5490e6050836f8f2f0d496b1c8d6a38d4ffac2b898e6e77751bdcd20ebf5.git/HEAD
ref: refs/heads/master

We have 3 gitlab instances: production, staging and dev. Gitlab version is 13.8.4. It has been installed with the gitlab chart 4.8.8 on kubernetes (AWS EKS). Each instance has 3 nodes gitaly and 3 nodes praefect.

On production env, we have the following different behaviour :

  • One gitaly node has a correct HEAD file, the 2 others have a bad one with master branch inside.
  • The prafect reconcile commands detects desynchronisation but the started reconcile jobs does not fix the synchronisation.

On dev env, all gitaly nodes have a bad HEAD file.

We have done a quick test with the last version of gitlab (13.11.4) but the problem still exists.

We have done another quick test on a standalone gitlab (omnibus, no praefect) and there is no problem. The HEAD file refers correctly the develop branch.

Results of GitLab environment info

Gitlab 13.8.4 with gitlab chart 4.8.4

gitlab-rake gitlab:env:info

System information System: Current User: git Using RVM: no Ruby Version: 2.7.2p137 Gem Version: 3.1.4 Bundler Version:2.1.4 Rake Version: 13.0.3 Redis Version: unknown Git Version: unknown Sidekiq Version:5.2.9 Go Version: unknown

GitLab information Version: 13.8.4 Revision: Directory: /srv/gitlab DB Adapter: PostgreSQL DB Version: 12.5 URL: https://code.gara.cloudgaz.com HTTP Clone URL: https://code.gara.cloudgaz.com/some-group/some-project.git SSH Clone URL: git@code-ssh.gara.cloudgaz.com:some-group/some-project.git Using LDAP: no Using Omniauth: no

GitLab Shell Version: 13.15.1 Repository storage paths:

  • default: /var/opt/gitlab/repo GitLab Shell path: /home/git/gitlab-shell Git: /usr/bin/git