首页 > 解决方案 > 无法将更改推送到管理员创建的分支

问题描述

所以我正在研究 Gitlab 。假装同时是管理员和合作者。

作为管理员:

作为合作方:

$ git init 
$ git config --global user.name "theslave"
$ git config --global user.email "theslave@gmail.com"
$ git remote add origin git@gitlab.com:theadmin/masterproject.git
$ git pull
$ git clone git@gitlab.com:theadmin/masterproject.git

是的,现在我将项目放入我的仓库中。修改文件,添加,提交。现在切换到分支

$ git checkout myslavebranch
$ git push

我得到了:

remote:
remote: ========================================================================
remote:
remote: You are not allowed to push code to this project.
remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.

这里有什么问题?管理员需要先给权限吗?是关于 SSH 的吗?错误的步骤?我想将我编辑的版本推送到管理员创建的分支。我该怎么做?

标签: gitgitlab

解决方案


检查存储库的权限。

我认为您需要成为开发人员、维护人员或所有者才能推送代码。贡献者通常需要类似的配置才能将代码推送到存储库中。例如,在大多数情况下,管理员应该将用户添加到存储库中作为“开发人员”,或者更好的角色来推送代码。或者管理员允许任何人推送代码。

参考:https ://docs.gitlab.com/ee/user/permissions.html

其他故障排除包括检查您的 SSH 公钥是否已在 gitlab 中正确注册并与您的帐户相关联。

另外,请检查管理员创建的分支是否受到保护。

参考:https ://docs.gitlab.com/ee/user/project/protected_branches.html


推荐阅读