需要从个人转换为工作git帐户



我一直在我的工作计算机Windows10上使用我的个人git和github帐户,但想开始使用工作帐户。

我在Github上创建了一个新的工作帐户和存储库。将存储库克隆到我的本地计算机后,进行提交然后尝试推动我会遇到以下错误。

git push
To https://github.com/workuser/workrepo.git
 ! [remote rejected] release -> release (permission denied)
error: failed to push some refs to 
'https://github.com/workuser/workrepo.git'

我正在使用VS代码

如果我运行

git config --get user.email

我收到我的工作电子邮件

在VS代码的终端中

git remote -v
origin  https://github.com/workuser/workrepo.git (fetch)
origin  https://github.com/workuser/workrepo.git (push)

我需要做什么,以便我可以在github上推到我的工作回购

谢谢

您尝试推到repo的 https 链接,而链接不起作用(不手动键入您的用户名和密码)。您必须使用 ssh 链接的版本!

更改远程来源的链接,在您的存储库中打开一个控制台,然后输入:

git remote set-url origin git@github.com:workuser/workrepo.git

现在您应该能够推到github。

我按照塞巴斯蒂安的建议(谢谢)并运行命令

git远程set-url rount git@github.com:workuser/workrepo.git

我从文件本地复制了我的SSH密钥c: users graeme.ssh id_rsa.pub

然后访问https://github.com/settings/keys,然后在此处添加