Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git Can';t推送链接到旧帐户_Git_Github - Fatal编程技术网

Git Can';t推送链接到旧帐户

Git Can';t推送链接到旧帐户,git,github,Git,Github,这个问题发生在我将git用户更改为新用户之后。 这就像我不能推我的当前用户,因为它仍然与旧帐户链接。我该如何解决这个问题 我已经做了: 创建新ssh 更新配置用户和电子邮件 我的用户已经使用github帐户(ssh-T)进行了身份验证git@github.com) 首先,如果您使用的是https url,ssh密钥将无关紧要。 使用git remote-v检查您的确切url 如果是https帐户,则强制在其中使用新用户名帐户: $ git push origin master remote:

这个问题发生在我将git用户更改为新用户之后。 这就像我不能推我的当前用户,因为它仍然与旧帐户链接。我该如何解决这个问题

我已经做了:

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

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

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

$ 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远程设置url https://@github.com//yourRepo
请注意,如果您正在推进非newusername直接拥有的回购,如您的“旧帐户”,您需要转到:

  • 要么回购,要么作为合作者添加
  • 或git push——将当前所有本地克隆的回购协议复制到一个新的空的
    yourRepo
    ,该新的回购协议是使用
    newusername
    GitHub帐户创建的

这是全新的,我从新的github帐户创建了存储库,然后将其克隆到本地,但无法推送。您的方式不起作用。我使用ssh链接再次尝试设置url,现在它起作用了。但这是什么意思?@user3045529通过使用ssh url,它必须使用正确的帐户。
git remote set-url https://<newusername>@github.com/<newusername>/yourRepo