“git推送”的权限被拒绝

“git推送”的权限被拒绝,git,Git,虽然我已经将ssh密钥添加到我的git帐户,但当我运行git push到远程repo时,我的权限被拒绝 $ cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC9TP2gLF0== mahmood@mahmood.com $ git push -u origin mahmood Username for 'https://github.com': mahmoodn Password for 'https://mahmoodn@github.com': remote:

虽然我已经将ssh密钥添加到我的git帐户,但当我运行git push到远程repo时,我的权限被拒绝

$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC9TP2gLF0== mahmood@mahmood.com
$ git push -u origin mahmood
Username for 'https://github.com': mahmoodn
Password for 'https://mahmoodn@github.com':
remote: Permission to gunrock/gunrock.git denied to mahmoodn.
fatal: unable to access 'https://github.com/gunrock/gunrock/': The requested URL returned error: 403
这是对我不是参与者或我自己的git帐户的远程回购的拒绝许可吗

更新:

嗯。我必须首先通过web将repo转移到我的帐户中,然后将origin设置为git remote set url originssh://git@github.com/mahmoodn/gunrock.git,然后是git-push-u-origin-mahmood


现在已修复。

这里有几个问题

首先,尽管您可能已经添加了SSH密钥,但看起来您仍然在使用HTTPS远程服务器。您可以使用git remote-v查看所有远程设备。如果您想使用SSH,您应该将URL从https://github.com/gunrock/gunrock.git 到ssh://git@github.com/gunrock/gunrock.git。您可以使用git远程设置url-origin来实现这一点ssh://git@github.com/gunrock/gunrock.git


其次,看起来您正试图推送到存储库gunrock/gunrock。如果是这种情况,您没有访问它的权限。如果你想把它推到你的叉子上,那么你会想推到你的叉子上ssh://git@github.com/mahmoodn/gunrock.git。您可以如上所述设置原点。

这里有几个问题

首先,尽管您可能已经添加了SSH密钥,但看起来您仍然在使用HTTPS远程服务器。您可以使用git remote-v查看所有远程设备。如果您想使用SSH,您应该将URL从https://github.com/gunrock/gunrock.git 到ssh://git@github.com/gunrock/gunrock.git。您可以使用git远程设置url-origin来实现这一点ssh://git@github.com/gunrock/gunrock.git


其次,看起来您正试图推送到存储库gunrock/gunrock。如果是这种情况,您没有访问它的权限。如果你想把它推到你的叉子上,那么你会想推到你的叉子上ssh://git@github.com/mahmoodn/gunrock.git。您可以如上所述设置来源。

正如您在更新中所述,您现在有两个独立的远程存储库。惯例是有两个遥控器:起点和上游

您的叉子是原点:

或其等价物

git remote set-url origin git@github.com:mahmoodn/gunrock.git
通过以下方式跟上gunrock/gunrock.git中的变化

现在,远程跟踪分支上游/主记录父存储库拥有其主存储库的位置。更新为

git fetch upstream

我建议您保持主机清洁,并始终与上游/主机保持同步


正如您在更新中所指出的,您现在有两个独立的远程存储库。惯例是有两个遥控器:起点和上游

您的叉子是原点:

或其等价物

git remote set-url origin git@github.com:mahmoodn/gunrock.git
通过以下方式跟上gunrock/gunrock.git中的变化

现在,远程跟踪分支上游/主记录父存储库拥有其主存储库的位置。更新为

git fetch upstream

我建议您保持主机清洁,并始终与上游/主机保持同步


输入的用户名与密钥中的电子邮件不匹配。是这样吗?你的意思是我必须在用户名字段中使用电子邮件吗?输入的用户名与密钥中的电子邮件不匹配。是这样吗?你的意思是我必须在用户名字段中使用电子邮件吗?我如何设置来源?你可以使用git remote set url设置来源url,其中url是你想要使用的url。我如何设置来源?你可以使用git remote set url设置来源url,其中url是你想要使用的url。
git fetch --all
git fetch --all
git checkout master
git merge --ff-only upstream/master