无法推送到Github的新回购

时间:2017-04-22 16:55:52

标签: git bash github

当我在GitHub中推送新的回购时,这是我的问题。

$ git push switchy master
remote: Permission to switchyofficial/switchy.git denied to jrey211995.
fatal: unable to access 'https://github.com/switchyofficial/switchy.git/': The requested URL returned error: 403

jrey211995是我的第一个帐户,然后我为我的新回购创建了另一个帐户。在那之后,我补充说,我提交了,然后当我把它推到我的新帐户时,问题总是出现,我该如何解决?

注意:当我在其中推送回购时,jrey211995设置为自动进行身份验证。

1 个答案:

答案 0 :(得分:3)

在本地项目的根目录中设置与新GitHub存储库关联的新用户名和电子邮件:

git config --local user.name yourusername
git config --local user.email youremail

然后运行以下命令:

git config --global credential.useHttpPath true

默认情况下,Git与网址的路径组件不匹配,因此GiHub上两个不同存储库的网址仍然只是Git的“https://github.com”。

credential.useHttpPath设置为true时,Git会将整个网址视为匹配。因此,您可以访问具有不同凭据的不同存储库。

相关问题