Can't push to GitLab repository from local server (hooks declined?)

走远了吗. 提交于 2019-12-08 04:46:47

问题


I have a local Git repository on the same server as a GitLab repository. I could pull, but not push. Since I am on the same server, I haven't bothered with SSH keys. Looking at GitLab's hooks tab, nothing is shown (Note that I have never used hooks, and really don't yet know their purpose). How is this resolved? Thank you

[root@vps bidjunction]# git remote -v
origin  /home/git/repositories/root/bidjunction.git (fetch)
origin  /home/git/repositories/root/bidjunction.git (push)

[root@vps bidjunction]# git push origin master
Counting objects: 25, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (14/14), done.
Writing objects: 100% (14/14), 2.31 KiB | 0 bytes/s, done.
Total 14 (delta 11), reused 0 (delta 0)
remote: GitLab: You are not allowed to access master!
remote: error: hook declined to update refs/heads/master
To /home/git/repositories/root/bidjunction.git
 ! [remote rejected] master -> master (hook declined)
error: failed to push some refs to '/home/git/repositories/root/bidjunction.git'
[root@vps bidjunction]#

回答1:


It can depend on the version of GitLab used:

That hook seems to be active by error after GitLab 6.7.x: see issue 6810.

After the upgrade, pushes to all repos started getting rejected with the following error message:

remote: GitLab: You are not allowed to access master!
remote: error: hook declined to update refs/heads/master

Downgrading back to 6.6.5 (and GitLab Shell 1.8.0) resolved the issue.

Note that it also mentions:

The resolution is to update the ldap section of gitlab.yml, wrapping all values currently wrapped in single quotes in double quotes instead.

Seems that only those using LDAP for auth are affected.


It could be also because the master branch is protected, as mentioned in issue 6968:

if I make master a protected branch, I can't push to it even though I am the owner of the project (see error below).
If I unprotect the master, then my push abilities are back.

I am on GitLab 6.8.2.



来源:https://stackoverflow.com/questions/23697580/cant-push-to-gitlab-repository-from-local-server-hooks-declined

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!