Project owner can't do the initial push

Summary

After creating a project using GitLab GUI, the owner can't do the initial push however a master can, when master did it, the owner can push to the master branch.

Steps to reproduce

You need two admin users :

  1. One (named "OwnerUser") will be the demo group creator and the demo project owner
  2. One (named "MasterUser") will be add as master of the project

We assume the GUI is at https://gitlab.lan/.

In the GUI, using user OwnerUser identified by LDAP :

  1. Create a new group "demo"
  2. Create a new project "demo" in the group "demo"
  3. Add user "MasterUser" to the demo/demo member's project list as master
[OwnerUser@myPC ~]$ git clone git@gitlab.lan:demo/demo.git
Cloning into 'demo'...
warning: You appear to have cloned an empty repository.
cd demo

Expected behavior

[OwnerUser@myPC ~/demo]$ touch README.md && git add README.md && git commit -m "add README" && git push origin master
[master (root-commit) .......] add README
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
Counting objects: 3, done.
Writing objects: 100% (3/3), 221 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@gitlab.lan:demo/demo.git
 * [new branch]      master -> master
[OwnerUser@myPC ~/demo]$

Actual behavior

[OwnerUser@myPC ~/demo]$ touch README.md && git add README.md && git commit -m "add README" && git push origin master
[master (root-commit) .......] add README
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 README.md
Counting objects: 3, done.
Writing objects: 100% (3/3), 221 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: GitLab: You are not allowed to push code to protected branches on this project.
To git@gitlab.lan:demo/demo.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@gitlab.lan:demo/demo.git'
[OwnerUser@myPC ~/demo]$

Relevant logs and/or screenshots

(Paste any relevant logs - please use code blocks (```) to format console output, logs, and code as it's very hard to read otherwise.)

Output of checks

(If you are reporting a bug on GitLab.com, write: This bug happens on GitLab.com)

gitLab data directory : nfs

[root@gitlab ~]# df -h /data
Filesystem            Size  Used Avail Use% Mounted on
[EDIT: remove IP]
xx.xx.xx.xx:/vol/gitlab
                      150G   39G  112G  26% /data
[root@gitlab ~]# 

Results of GitLab application Check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

[root@gitlab ~]# gitlab-rake gitlab:check SANITIZE=true
Checking GitLab Shell ...

GitLab Shell version >= 4.1.1 ? ... OK (4.1.1)
Repo base directory exists?
default... yes
Repo storage directories are symlinks?
default... no
Repo paths owned by git:git?
default... yes
Repo paths access is drwxrws---?
default... yes
hooks directories in repos are links: ... 
7/1 ... ok
13/3 ... ok
14/5 ... ok
14/7 ... ok
14/8 ... ok
14/9 ... ok
14/10 ... ok
14/11 ... ok
14/12 ... ok
14/13 ... ok
14/14 ... ok
13/15 ... ok
13/16 ... ok
13/17 ... ok
13/18 ... ok
14/19 ... ok
13/20 ... ok
34/23 ... ok
14/24 ... ok
14/25 ... ok
14/28 ... ok
14/29 ... ok
14/30 ... ok
14/31 ... ok
14/32 ... ok
14/33 ... ok
13/35 ... ok
13/36 ... ok
13/40 ... ok
13/42 ... ok
25/44 ... repository is empty
13/46 ... ok
14/47 ... ok
13/48 ... ok
40/50 ... ok
14/89 ... ok
25/121 ... ok
14/122 ... ok
14/123 ... ok
13/124 ... ok
25/127 ... ok
25/128 ... ok
25/129 ... ok
25/130 ... ok
25/131 ... repository is empty
53/132 ... ok
13/134 ... ok
53/135 ... ok
58/136 ... ok
59/137 ... repository is empty
13/144 ... ok
13/145 ... ok
13/147 ... ok
13/148 ... ok
13/149 ... ok
13/153 ... ok
13/160 ... ok
13/161 ... ok
13/163 ... ok
13/164 ... ok
13/165 ... ok
13/166 ... ok
13/167 ... ok
13/168 ... ok
13/171 ... ok
13/173 ... ok
13/174 ... repository is empty
25/175 ... repository is empty
13/176 ... ok
72/178 ... ok
40/179 ... ok
13/180 ... ok
71/182 ... ok
2/184 ... ok
69/185 ... ok
25/186 ... ok
78/189 ... ok
13/193 ... ok
13/194 ... ok
13/195 ... ok
13/196 ... ok
61/197 ... ok
13/198 ... ok
13/201 ... ok
13/202 ... ok
13/203 ... ok
25/204 ... ok
13/205 ... repository is empty
13/206 ... ok
13/207 ... ok
13/209 ... ok
34/210 ... ok
25/211 ... repository is empty
34/213 ... ok
89/218 ... ok
44/219 ... ok
90/220 ... ok
88/221 ... ok
71/222 ... ok
71/223 ... ok
13/224 ... ok
13/225 ... ok
13/226 ... ok
88/227 ... ok
71/228 ... ok
93/229 ... ok
13/230 ... ok
13/231 ... ok
13/232 ... ok
13/234 ... ok
98/235 ... ok
13/236 ... ok
13/237 ... ok
98/238 ... ok
13/239 ... ok
13/242 ... ok
13/243 ... ok
13/244 ... ok
13/245 ... ok
13/246 ... ok
13/247 ... ok
13/248 ... ok
13/249 ... ok
98/250 ... ok
98/251 ... ok
98/252 ... ok
34/253 ... ok
13/254 ... ok
98/255 ... ok
13/256 ... repository is empty
13/263 ... ok
56/264 ... repository is empty
101/265 ... ok
98/266 ... ok
13/267 ... ok
98/268 ... ok
98/272 ... ok
98/273 ... ok
98/274 ... ok
56/275 ... ok
98/276 ... ok
98/277 ... ok
98/278 ... ok
102/281 ... ok
13/282 ... ok
98/283 ... ok
98/284 ... ok
98/285 ... ok
98/286 ... ok
73/291 ... repository is empty
13/296 ... ok
13/297 ... ok
13/298 ... ok
13/300 ... ok
13/301 ... ok
104/302 ... ok
98/338 ... repository is empty
104/343 ... repository is empty
102/345 ... ok
13/346 ... ok
13/348 ... ok
13/349 ... ok
56/350 ... ok
104/358 ... ok
104/361 ... ok
104/362 ... ok
13/363 ... ok
56/364 ... ok
104/365 ... repository is empty
104/366 ... ok
96/367 ... ok
13/368 ... ok
73/371 ... repository is empty
13/372 ... ok
13/373 ... ok
13/374 ... ok
56/376 ... ok
13/378 ... repository is empty
102/379 ... ok
102/380 ... ok
102/381 ... ok
13/382 ... ok
13/383 ... ok
108/384 ... repository is empty
98/385 ... ok
13/386 ... ok
25/387 ... repository is empty
13/395 ... ok
13/396 ... ok
13/397 ... ok
13/398 ... ok
13/399 ... ok
13/400 ... ok
13/401 ... ok
13/402 ... ok
13/403 ... ok
13/404 ... ok
13/417 ... ok
13/419 ... ok
13/420 ... ok
13/421 ... ok
13/422 ... ok
13/425 ... ok
13/426 ... ok
13/427 ... ok
30/428 ... repository is empty
25/429 ... ok
123/431 ... ok
13/432 ... ok
96/433 ... ok
13/434 ... ok
34/437 ... ok
13/439 ... ok
98/440 ... ok
13/444 ... ok
13/450 ... ok
13/451 ... ok
13/452 ... ok
121/453 ... ok
13/455 ... ok
98/456 ... ok
13/460 ... ok
13/461 ... ok
98/462 ... ok
13/463 ... ok
34/465 ... ok
98/466 ... ok
13/467 ... ok
98/468 ... ok
13/469 ... ok
25/470 ... repository is empty
13/471 ... ok
61/472 ... ok
13/475 ... ok
13/476 ... repository is empty
98/492 ... ok
98/493 ... ok
8/495 ... ok
138/496 ... ok
38/497 ... ok
34/499 ... repository is empty
138/501 ... ok
13/503 ... repository is empty
13/504 ... ok
138/505 ... ok
25/506 ... ok
34/507 ... ok
25/508 ... ok
13/509 ... ok
138/510 ... ok
13/511 ... ok
25/512 ... ok
26/513 ... ok
26/514 ... repository is empty
139/515 ... ok
34/518 ... ok
102/519 ... ok
25/522 ... ok
25/523 ... ok
104/525 ... ok
104/527 ... ok
13/528 ... ok
104/541 ... repository is empty
104/542 ... repository is empty
104/543 ... repository is empty
104/544 ... repository is empty
104/545 ... repository is empty
104/546 ... repository is empty
104/547 ... repository is empty
104/548 ... repository is empty
104/549 ... repository is empty
104/550 ... repository is empty
104/551 ... repository is empty
104/552 ... repository is empty
104/553 ... repository is empty
13/571 ... ok
138/572 ... repository is empty
13/574 ... ok
13/575 ... ok
13/577 ... ok
141/578 ... ok
141/579 ... ok
141/580 ... ok
141/581 ... ok
144/591 ... ok
Running /opt/gitlab/embedded/service/gitlab-shell/bin/check
Check GitLab API access: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: OK
Send ping to redis server: OK
gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Sidekiq ...

Running? ... yes
Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Reply by email ...

Reply by email is disabled in config/gitlab.yml

Checking Reply by email ... Finished

Checking LDAP ...

Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
	DN: CN=...  
[EDIT: ldap data removed]

Checking LDAP ... Finished

Checking GitLab ...

Git configured with autocrlf=input? ... yes
Database config exists? ... yes
All migrations up? ... yes
Database contains orphaned GroupMembers? ... no
GitLab config exists? ... yes
GitLab config outdated? ... no
Log directory writable? ... yes
Tmp directory writable? ... yes
Uploads directory setup correctly? ... yes
Init script exists? ... skipped (omnibus-gitlab has no init script)
Init script up-to-date? ... skipped (omnibus-gitlab has no init script)
projects have namespace: ... 
7/1 ... yes
13/3 ... yes
14/5 ... yes
14/7 ... yes
14/8 ... yes
14/9 ... yes
14/10 ... yes
14/11 ... yes
14/12 ... yes
14/13 ... yes
14/14 ... yes
13/15 ... yes
13/16 ... yes
13/17 ... yes
13/18 ... yes
14/19 ... yes
13/20 ... yes
34/23 ... yes
14/24 ... yes
14/25 ... yes
14/28 ... yes
14/29 ... yes
14/30 ... yes
14/31 ... yes
14/32 ... yes
14/33 ... yes
13/35 ... yes
13/36 ... yes
13/40 ... yes
13/42 ... yes
25/44 ... yes
13/46 ... yes
14/47 ... yes
13/48 ... yes
40/50 ... yes
14/89 ... yes
25/121 ... yes
14/122 ... yes
14/123 ... yes
13/124 ... yes
25/127 ... yes
25/128 ... yes
25/129 ... yes
25/130 ... yes
25/131 ... yes
53/132 ... yes
13/134 ... yes
53/135 ... yes
58/136 ... yes
59/137 ... yes
13/144 ... yes
13/145 ... yes
13/147 ... yes
13/148 ... yes
13/149 ... yes
13/153 ... yes
13/160 ... yes
13/161 ... yes
13/163 ... yes
13/164 ... yes
13/165 ... yes
13/166 ... yes
13/167 ... yes
13/168 ... yes
13/171 ... yes
13/173 ... yes
13/174 ... yes
25/175 ... yes
13/176 ... yes
72/178 ... yes
40/179 ... yes
13/180 ... yes
71/182 ... yes
2/184 ... yes
69/185 ... yes
25/186 ... yes
78/189 ... yes
13/193 ... yes
13/194 ... yes
13/195 ... yes
13/196 ... yes
61/197 ... yes
13/198 ... yes
13/201 ... yes
13/202 ... yes
13/203 ... yes
25/204 ... yes
13/205 ... yes
13/206 ... yes
13/207 ... yes
13/209 ... yes
34/210 ... yes
25/211 ... yes
34/213 ... yes
89/218 ... yes
44/219 ... yes
90/220 ... yes
88/221 ... yes
71/222 ... yes
71/223 ... yes
13/224 ... yes
13/225 ... yes
13/226 ... yes
88/227 ... yes
71/228 ... yes
93/229 ... yes
13/230 ... yes
13/231 ... yes
13/232 ... yes
13/234 ... yes
98/235 ... yes
13/236 ... yes
13/237 ... yes
98/238 ... yes
13/239 ... yes
13/242 ... yes
13/243 ... yes
13/244 ... yes
13/245 ... yes
13/246 ... yes
13/247 ... yes
13/248 ... yes
13/249 ... yes
98/250 ... yes
98/251 ... yes
98/252 ... yes
34/253 ... yes
13/254 ... yes
98/255 ... yes
13/256 ... yes
13/263 ... yes
56/264 ... yes
101/265 ... yes
98/266 ... yes
13/267 ... yes
98/268 ... yes
98/272 ... yes
98/273 ... yes
98/274 ... yes
56/275 ... yes
98/276 ... yes
98/277 ... yes
98/278 ... yes
102/281 ... yes
13/282 ... yes
98/283 ... yes
98/284 ... yes
98/285 ... yes
98/286 ... yes
73/291 ... yes
13/296 ... yes
13/297 ... yes
13/298 ... yes
13/300 ... yes
13/301 ... yes
104/302 ... yes
98/338 ... yes
104/343 ... yes
102/345 ... yes
13/346 ... yes
13/348 ... yes
13/349 ... yes
56/350 ... yes
104/358 ... yes
104/361 ... yes
104/362 ... yes
13/363 ... yes
56/364 ... yes
104/365 ... yes
104/366 ... yes
96/367 ... yes
13/368 ... yes
73/371 ... yes
13/372 ... yes
13/373 ... yes
13/374 ... yes
56/376 ... yes
13/378 ... yes
102/379 ... yes
102/380 ... yes
102/381 ... yes
13/382 ... yes
13/383 ... yes
108/384 ... yes
98/385 ... yes
13/386 ... yes
25/387 ... yes
13/395 ... yes
13/396 ... yes
13/397 ... yes
13/398 ... yes
13/399 ... yes
13/400 ... yes
13/401 ... yes
13/402 ... yes
13/403 ... yes
13/404 ... yes
13/417 ... yes
13/419 ... yes
13/420 ... yes
13/421 ... yes
13/422 ... yes
13/425 ... yes
13/426 ... yes
13/427 ... yes
30/428 ... yes
25/429 ... yes
123/431 ... yes
13/432 ... yes
96/433 ... yes
13/434 ... yes
34/437 ... yes
13/439 ... yes
98/440 ... yes
13/444 ... yes
13/450 ... yes
13/451 ... yes
13/452 ... yes
121/453 ... yes
13/455 ... yes
98/456 ... yes
13/460 ... yes
13/461 ... yes
98/462 ... yes
13/463 ... yes
34/465 ... yes
98/466 ... yes
13/467 ... yes
98/468 ... yes
13/469 ... yes
25/470 ... yes
13/471 ... yes
61/472 ... yes
13/475 ... yes
13/476 ... yes
98/492 ... yes
98/493 ... yes
8/495 ... yes
138/496 ... yes
38/497 ... yes
34/499 ... yes
138/501 ... yes
13/503 ... yes
13/504 ... yes
138/505 ... yes
25/506 ... yes
34/507 ... yes
25/508 ... yes
13/509 ... yes
138/510 ... yes
13/511 ... yes
25/512 ... yes
26/513 ... yes
26/514 ... yes
139/515 ... yes
34/518 ... yes
102/519 ... yes
25/522 ... yes
25/523 ... yes
104/525 ... yes
104/527 ... yes
13/528 ... yes
104/541 ... yes
104/542 ... yes
104/543 ... yes
104/544 ... yes
104/545 ... yes
104/546 ... yes
104/547 ... yes
104/548 ... yes
104/549 ... yes
104/550 ... yes
104/551 ... yes
104/552 ... yes
104/553 ... yes
13/571 ... yes
138/572 ... yes
13/574 ... yes
13/575 ... yes
13/577 ... yes
141/578 ... yes
141/579 ... yes
141/580 ... yes
141/581 ... yes
144/591 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.1.0 ? ... yes (2.3.3)
Your git bin path is "/opt/gitlab/embedded/bin/git"
Git version >= 2.7.3 ? ... yes (2.8.4)
Active users: 96

Checking GitLab ... Finished

[root@gitlab ~]# 

(we will only investigate if the tests are passing)

Results of GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:env:info)

[root@gitlab ~]# gitlab-rake gitlab:env:info

System information
System:		
Current User:	git
Using RVM:	no
Ruby Version:	2.3.3p222
Gem Version:	2.6.6
Bundler Version:1.13.7
Rake Version:	10.5.0
Sidekiq Version:4.2.7

GitLab information
Version:	8.15.2
Revision:	790035f
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	postgresql
URL:		https://gitlab.lan
HTTP Clone URL:	https://gitlab.lan/some-group/some-project.git
SSH Clone URL:	git@gitlab.lan:some-group/some-project.git
Using LDAP:	yes
Using Omniauth:	no

GitLab Shell
Version:	4.1.1
Repository storage paths:
- default: 	/data/git-data/repositories
Hooks:		/opt/gitlab/embedded/service/gitlab-shell/hooks/
Git:		/opt/gitlab/embedded/bin/git
[root@gitlab ~]# 

Possible fixes

(If you can, link to the line of code that might be responsible for the problem) Sorry, I can't.