2016-12-14 77 views
1

我在Github上有兩個帳戶(假設它們是a1a2)。用我的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帳戶後?

+0

它是否要求您在嘗試執行「推」時進行身份驗證?你有可能使用[憑證助手來緩存你的github密碼](https://help.github.com/articles/caching-your-github-password-in-git/)? –

+0

它沒有要求我進行身份驗證,但是當我鍵入'git config --list'時,我可以看到'credential.helper'設置爲'osxkeychain'(我在Mac上)。 – Giorgio

+0

你有沒有試過去鑰匙串,並刪除那裏所有github憑證(考慮你知道你的憑證,並可以登錄沒有鑰匙串),重新啓動機器,並檢查你是否會被要求憑證下次嘗試'推'? –

回答

0

從GitHub文檔:

如果您使用HTTPS克隆GitHub的倉庫,你可以使用一個 credential helper 通知Git記住每次 它談論到你的GitHub的GitHub上的用戶名和密碼。

如果這是您的情況,在MacOS上,您的憑證將存儲在您的鑰匙串中。您可以通過運行以下命令確認這一點:

git config --list 

查看是否有credential.helper設置爲osxkeychain

強制Git詢問你的github憑證的最簡單的方法是去你的鑰匙鏈,並刪除那裏所有的Github條目。