After cloning a git repository from my gitlab server, it does not checkout master, as origin/HEAD points to some other branch 'origin/foo'. In gitlab, the default branch is set to master.
How can I move origin/HEAD from 'origin/foo' to point to 'origin/master', so that further clones automatically check out origin/master?
Right after cloning, git remote show origin states:
HEAD branch: foo
git remote -r seconds that:
origin/HEAD -> origin/foo
I want the HEAD branch to point to master, though - inside gitlab - the default branch is already set to master.
In order to clone a specific branch, you have to execute “git branch” with the “-b” and specify the branch you want to clone. $ git clone -b dev https://github.com/username/project.git Cloning into 'project'... remote: Enumerating objects: 813, done.
git clone --single-branch : By default, git clone will create remote tracking branches for all of the branches currently present in the remote which is being cloned. The only local branch that is created is the default branch.
While you can clone repositories with the git clone command, keep in mind that this clones the branch and the remote HEAD . This is usually master by default and includes all other branches in the repository. So when you clone a repository, you clone the master and all other branches.
This can be done only server-side. For GitLab, it is done in your project, Settings (last item in the sidebar on the left), "Default Branch" (third text field).
Apparently there is an issue at the moment (March 2016) which means that the default branch reported by GitLab is not always the same as the HEAD branch reported by git remote show origin
. Setting the GitLab default branch to anything else, then setting it back to master, has worked for @rralf.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With