我在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凭证(考虑你知道你的凭证,并可以登录没有钥匙串),重新启动机器,并检查你是否会被要求凭证下次尝试'推'? –