一、问题
git push代码时出现:
You are not allowed to push code to a protected branch on this project.
二、问题解决
1. 确定代码自己是有权限的(上传哪个分支就需要具有分支权限。如果没有master权限是不能推送到master分支的)
2.一般情况下需要清空git代理
# 全局:查看 Git 代理
git config --global --get http.proxy
# 全局:删除 Git 代理
git config --global --unset http.proxy
3.上述办法均无效时,我把git存储的账号密码清空之后,解决问题
查看是否缓存:
git config credential.helper
如果你的电脑本来就有.gitconfig文件, 找到下面这句话删除,保存退出。
[credential] helper = xxx
如果输入了 git config credential.helper
命令之后还是出现了osxkeychain, store 或者 cache 等,可以使用一下命令参看电脑中所有存在git credential配置的文件。
git config --show-origin --get credential.helper
参考文章
git 的密码删除和重新配置可以参考下面这篇文章: