Git:允许[组织]拒绝[用户]

时间:2016-12-14 16:22:34

标签: git github git-push git-config

我在Github上有两个帐户(假设他们是a1a2)。使用我的a2配置文件,我为它创建了一个origanization和一个新的存储库(来自Github的网站)。我的电脑有以下~/.gitconfig文件:

[core]
    editor = pico
[user]
    name = a1
    email = mail_a1@example.com

(因为我大部分时间都使用a1帐户)。

现在我想使用a2创建我所创建的组织的存储库,因此我执行了以下操作:

cd project_folder
touch README.md
git init
git config --local user.name a2
git config --local user.email "mail_a2@example.com"
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 <mail_a2@example.com>
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帐户配置我的本地存储库之后呢?

1 个答案:

答案 0 :(得分:0)

来自github文档:

  

如果您使用HTTPS克隆GitHub存储库,则可以使用   credential helper   告诉Git每次都记住你的GitHub用户名和密码   它与GitHub交谈。

如果是这种情况,在MacOS上,您的凭据将存储在您的钥匙串中。您可以通过运行以下命令来确认:

git config --list

查看您是否credential.helper设置为osxkeychain

强制Git请求你的github凭据的最简单方法是转到你的钥匙串并删除所有Github条目。

相关问题