git push 程式碼到遠端倉庫報錯
阿新 • • 發佈:2022-03-31
Github環境配置報錯, Push程式碼報錯remote: Permission to A denied to B
背景
今天換新電腦,準備配置下github的環境,拉下新專案後,在更新完程式碼做完修改後,準備提交的過程中,git push失敗了,出現remote: Permission to A denied to B
的問題。
問題原因
原電腦上,之前有登陸過其它的github賬號,然後登陸時,預設就採用的這個賬號xxx登陸了,然後push時,就報錯remote: Permission to A denied to XXX
。
解決方案
- 把電腦上github的賬號和密碼修改成我想登陸的
去 Control Panel\User Accounts\Credential Manager
再一次push,報新的錯誤,究其原因,其實是因為github的機制變了。
具體資訊,可以參考提示裡的 https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ 的說明,有更細的描述。
- 把原電腦上的歷史賬號刪除
去 Control Panel\User Accounts\Credential Manager
裡,將 https://github.com 對應的 Credential刪除。
然後再次去push,就會彈出認證選項,可以採用device authorization驗證通過後,github就綁定了對應的裝置
再提交,已可以push上去。