repositories' HEAD changed from master to main while restoring backup
Summary
I have migrated a GitLab instance from omnibus to Kubernetes. After migration, cloning a repository produces an empty directory and emits the following warning: remote HEAD refers to nonexistent ref, unable to checkout.
Steps to reproduce
- A GitLab omnibus instance where the default branch is
master(updated to 14.5.0) - Migrate the instance to Kubernetes following this guide
- Clone any repository
What is the current bug behavior?
$ git clone git@xxx:xxx/xxx
Cloning into 'xxx'...
remote: Enumerating objects: 57, done.
remote: Counting objects: 100% (57/57), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 57 (delta 32), reused 57 (delta 32), pack-reused 0
Receiving objects: 100% (57/57), 6.45 KiB | 2.15 MiB/s, done.
Resolving deltas: 100% (32/32), done.
warning: remote HEAD refers to nonexistent ref, unable to checkout.
What is the expected correct behavior?
The repository should be successfully cloned.
Possible fixes
I went into the gitaly container and found that the content of the HEAD files in all repositories have been changed from ref: refs/heads/master to ref: refs/heads/main, which leads to the non-existent main branch.
Workaround: find /home/git/repositories -name HEAD -exec sed -i "s/main/master/g" {} \;