gitlab shows repo as empty if main ref is missing
Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.
Summary
- GitLab will show a repository as empty even though it contains data if no main branch ref has been pushed.
- Some actions may cleanup such a repository and "empty" it again (I think it was caused by changing from private to public)
- GitLab server rejects updating hidden refs even though the repo didn't exist (or is empty)
Steps to reproduce
- Init an empty git bare repo
git init --bare .
- add an existing repository as origin remote.
git remote add origin https://github.com/ansible-collections/community.kubernetes.git
- add a not yet existing gitlab repo as remote
git remote add gitlab git@gitlab.com:agowa/not-really-empty.git
- run
git fetch origin --all
- run
git branch --all
and note that no local branches exist only theremotes/origin/*
ones. - set
git config remote.$remoteName.mirror true
(server will reject some refs, including refs/remote/*/main, hence why the branch isn't created to begin with; And without this the push will fail with "No refs in common and none specified; doing nothing") -
git push gitlab --all
(orgit push gitlab --mirror
) - Open the gitlab repo in a web browser.
- See that the repo appears empty in the web browser.
When comparing a new independent git clone --bare
of both remotes one can see that some refs (refs/heads/main
and refs/heads/stable-1.2
in this case) have not been created on the gitlab side.
(And yes, I also had an error in my script, as I didn't create any refs within the git bare repo itself which would have avoided this issue as git would have created the remote branches within the gitlab repo automatically, well at least if push.autoSetupremote is set to true; but regardless of that gitlab should not show a repo that contains data of any sort as empty)
Example Project
https://gitlab.com/agowa/not-really-empty
What is the current bug behavior?
Repo erroneously shown as empty in the web browser.
What is the expected correct behavior?
Repo should be shown even if no branch exists but objects have been pushed. Especially if tags also exist.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)