1. 程式人生 > >git error: You are not allowed to push code to a protected branch on this project 解決

git error: You are not allowed to push code to a protected branch on this project 解決

一、問題

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
找到對應的檔案之後。上傳對應的 :credential.helper = XXXX


參考文章

git 的密碼刪除和重新配置可以參考下面這篇文章: