Ignore default branch protection for first push
Problem to solve
When Default branch protection is set to Fully protected developers cannot push new commits to the default branch. Because default branch is set by the first push, this means that only a maintainer can perform the first push. When developers hit this situation it is not obvious why this is the case and can be annoying.
Currently the following warning is shown https://gitlab.com/gitlab-org/gitlab-ce/issues/27456:
remote:
remote: A default branch (e.g. master) does not exist for example/project.git
remote: Ask the project Owner or Maintainer to create a default branch.
remote:
remote: https://gitlab.com/example/project/project_members
remote:
To gitlab.com:example/project.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.com:example/project.git'
Further details
Here are some workflows where this issue is problematic:
Existing repository – a new empty project is created for a developer to push an existing project with an existing history. The developer should be able to push the master branch and all it's history.
Proposal
Ignore the default branch protection for the first push.
Links / references
Edited by James Ramsay (ex-GitLab)