Git无法推送链接到旧帐户

时间:2015-09-27 06:18:47

标签: git github

$ git push origin master
remote: Permission to xxx/test.git denied to OLDUSER.
fatal: unable to access 'https://github.com/xxx/test.git/': The requested URL
returned error: 403

我将git用户更改为新用户后出现此问题。 这就是我无法推动当前用户,因为它仍然与旧帐户相关联。我该如何解决这个问题?

我已经做过的事情:

  • 创建新的ssh
  • 更新配置用户&电子邮件
  • 我的用户已使用github帐户进行身份验证(ssh -T git@github.com)

1 个答案:

答案 0 :(得分:0)

首先,如果您使用的是https网址,则ssh密钥无关紧要 使用git remote -v检查您的确切网址。

如果是https版,请在其中强制使用新的用户名帐户:

git remote set-url https://<newusername>@github.com/<newusername>/yourRepo

请注意,如果您要推送的新帐户并非直接拥有,例如您的“旧帐户”,则需要转到:

  • 要么回购并添加<newusername>作为协作者
  • 或git push - 将您当前的本地克隆回购邮件发送到使用yourRepo GitHub帐户创建的新空newusername
相关问题