有一次在用github上傳code時出現了這樣的問題
remote: Permission to GitUser/SomeProject.git denied to gitUser.
fatal: unable to access 'https://github.com/GitUser/SomeProject.git/': The requested URL returned error: 403
原因應該是因為我有多個github帳號(公司跟私人)導致的
到該repo
下的.git/config
編輯一下url
原本是url = https://github.com/GitUser/SomeProject.git
改成url = https://GitUser@github.com/GitUser/SomeProject.git
重新跑push時就會問這個帳密的密碼
~/git/SomeProject(master) » git push -u origin master
Password for 'https://GitUser@github.com':
正確輸入後就會正常上傳了
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (4/4), 1023 bytes | 511.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0)
To https://github.com/GitUser/SomeProject.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.