If your first (default) branch is not named "master", the remote/origin/HEAD doesn't seem to be set
I'm using GitLab CE 7.10.1 installed with the omnibus package (7.10.1~omnibus.2-1) on Ubuntu 14.04
On a newly empty project, if the first (default) branch pushed is not named master, remote/origin/HEAD is not set. So whenever you try to clone the repo, you end up with the following message : warning: remote HEAD refers to nonexistent ref, unable to checkout.
I know that if you don't specify the branch name in your clone command, git will assume the remote branch to be "master" but HEAD should be pointing to the default branch of your project so that your clone command work seamlessly. Plus, this seems to lead to another issue I opened a few days ago (and may even be the root cause): #1561 (closed)
Steps to reproduce :
- Create a new project
- Prepare your local repo : git init, add your files, commit locally and add your origin
- Now rename your local "master" branch to something (say "prod") :
git branch -m master prod
- Push it upstream :
git push -u origin prod
- Your gitlab repository now contains one branch "prod" set as the default branch and protected
- Get info about your origin :
git remote show origin
. Here's the output:
* remote origin
Fetch URL: git@your_server:namespace/your_project.git
Push URL: git@your_server:namespace/your_project.git
HEAD branch: (unknown)
Remote branch:
prod tracked
Local branch configured for 'git pull':
prod merges with remote prod
Local ref configured for 'git push':
prod pushes to prod (up to date)
The interesting part is the line HEAD branch which is pointing to unknown. If you follow the exact same steps except for the renaming part (i.e. you keep the default name to "master"), you have the following output:
* remote origin
Fetch URL: git@your_server:namespace/your_project.git
Push URL: git@your_server:namespace/your_project.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
In this case the output shows a correct remote HEAD pointing to master. In the first case described, the remote HEAD should be pointing to the prod branch instead of not being set as it is the default branch of your repo.
As mentioned in the beginning, this seems to be the root cause of #1561 (closed) To get a correct behavior, you need to create another branch and push it upstream. This new branch wrongly becomes the default branch of your project (as described in #1561 (closed)). Then you have to manually reset your default branch through your project settings. After that, the behavior for newly created branches will be correct and your remotes/origin/HEAD will be correctly pointing to your original default branch.
So to sum up this kinda monster block of text, it's as if gitlab were ignoring you very first branch pushed upstream when it's not named "master" even if you do see it set as the default one through the UI.
Don't hesitate to correct me if I didn't follow some guidelines
Regards