2016-12-14 79 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条目。