场景
使用 git push 向自己的 Gitlab 仓库更新代码时报错 remote: GitLab: You are not allowed to push code to protected branches on this project.
想起来现在自己 git 的 token 是 github 的 token,对自己 gitlab 的仓库还是没有权限,那我要如何添加 gitlab 仓库权限呢。
方法
【STEP 1】Github 生成 token
settings->developer settings ->personal access tokens-generate new token
一定要保存 token 值再关闭页面,token 只会在创建的时候能被复制
【STEP 2】设置仓库 token
首次设置token :
git remote add origin https://<GitHub用户名>:<token值>@github.com/1234567/develop.git
重设token:
git remote set-url origin https://<Gitlab用户名>:<token值>@gitlab.scumaker.org/组织名/仓库名
然后按照之前的 git push -u origin master
即可