Skip to content

Improve feedback when a developer cannot push in an empty repository

When a new project is created by a Master for a Developer, the project will be empty and the Developer will not be able to push because the default branch (which is the first branch pushed) is Fully Protected (developers cannot push new commits, but masters can. No-one can force push or delete the branch). This is not an obvious consequence.

We should make it clearer to developers why their pushes are being rejected (this issue), and give a one-click solution for creating a repository with a protected master branch, ready for the developer to push to any other branch (https://gitlab.com/gitlab-org/gitlab-ce/issues/19468)

Proposal

To catch any situation where the repo is completely empty if a Developer tries to push we should show better feedback about how to resolve it.

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'

Links

https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/6608

Original bug report

Summary

Cannot create/push master branch in an empty repository as developer

Steps to reproduce

  1. create a new repository in GitLab
  2. init a new git repo in your filesystem
  3. commit an initial set of changes on master
  4. add the empty gitlab repo as remote
  5. try to push as a developer role

Expected behavior

I should be able to initiate the master branch in an empty repository also as developer.

Actual behavior

You are not allowed to push code to protected branches on this project.

developer role is not able to create a new repository

Edited by Jeethu Karthik