我在Github上有兩個帳戶(假設它們是a1
和a2
)。用我的a2
配置文件,我爲它創建了一個組織機構和一個新的存儲庫(來自Github的網站)。我的電腦有以下~/.gitconfig
文件:Git:[組織]的權限被拒絕給[用戶]
[core]
editor = pico
[user]
name = a1
email = [email protected]
(因爲大部分時間我用我的a1
帳戶)。
現在,我想在我a2
創建的組織的倉庫工作,所以我做了以下內容:
cd project_folder
touch README.md
git init
git config --local user.name a2
git config --local user.email "[email protected]"
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/myorganisation/myrepo.git
然後,只是要確定我提交來自a2
做的,我做了git log
,獲得:
commit e8dd182a12023a490cb2f099ea8b3a94afe6b81b
Author: a2 <[email protected]>
Date: Wed Dec 14 17:12:10 2016 +0100
first commit
太好了。但是,當我試圖git push -u origin master
,我得到了一個403的消息說,我努力推動爲a1
:
remote: Permission to hivex-unipd/swedesigner.git denied to gigiobello.
fatal: unable to access 'https://github.com/myorganisation/myrepo.git/': The requested URL returned error: 403
我是不是忘了什麼東西? 爲什麼Github認爲我是a1
即使在我配置我的本地存儲庫與a2
帳戶後?
它是否要求您在嘗試執行「推」時進行身份驗證?你有可能使用[憑證助手來緩存你的github密碼](https://help.github.com/articles/caching-your-github-password-in-git/)? –
它沒有要求我進行身份驗證,但是當我鍵入'git config --list'時,我可以看到'credential.helper'設置爲'osxkeychain'(我在Mac上)。 – Giorgio
你有沒有試過去鑰匙串,並刪除那裏所有github憑證(考慮你知道你的憑證,並可以登錄沒有鑰匙串),重新啓動機器,並檢查你是否會被要求憑證下次嘗試'推'? –