[git]使用push提交到遠端倉庫出現 The requested URL returned error: 403 錯誤
摘要:使用push提交到遠端倉庫出現 The requested URL returned error: 403 錯誤的解決方法。
問題描述
- 這臺電腦已經註冊過一個github帳號,一直在本機使用,配置過SSH。
- 今天新建了一個github帳號,本地建立好專案之後,使用命令:
$ git push -u origin master
時出現以下錯誤(這裡使用https方式,如果使用SSH方式需要另外做配置,可參考我的另一篇相關文章: ofollow,noindex">單臺機器使用多個SSH公鑰連線多個github遠端倉庫 )。
remote: Permission to userName/repositorieName.git denied to clxering. fatal: unable to access 'https://github.com/userName/repositorieName.git/': The requested URL returned error: 403
問題原因
問題主要出在原有賬號上,系統儲存了原賬號的資訊。在使用新帳號時,資訊不一致,所以報錯。
解決
- 開啟cmd,輸入命令:
rundll32.exe keymgr.dll,KRShowKeyMgr
,出現儲存的使用者名稱和密碼視窗 -
在下圖中將github相關的條目刪除
紅框部分為已經儲存的github賬戶資訊
- 重新執行命令:
$ git push -u origin master
,輸入賬戶名及密碼後,提示成功。
Counting objects: 9, done. Delta compression using up to 8 threads. Compressing objects: 100% (4/4), done. Writing objects: 100% (9/9), 716 bytes | 716.00 KiB/s, done. Total 9 (delta 0), reused 6 (delta 0) To https://github.com/userName/repositorieName.git * [new branch]master -> master Branch 'master' set up to track remote branch 'master' from 'origin'.