一切都运行正常,直到我创建一个新的GitHub帐户.当我尝试使用新帐户将代码第一次推送到github服务器时,发生以下错误:
remote: Permission to NEW_USER/NEW_REPO.git denied to OLD_USER.
fatal: unable to access 'https://github.com/NEW_USER/NEW_REPO/': The requested URL returned error: 403
Run Code Online (Sandbox Code Playgroud)
试图使用以下方法重置远程URL:
$git remote set-url origin https://username@github.com/user/repo.git ......但没有工作.
这里有一个解决方案,但适用于Mac OS.任何想法如何解决这个问题.运用git bash version 2.16.1.windows.4.
谢谢
cod*_*ant 18
当在同一台机器上使用两个git帐户时会发生这种情况.在Windows 7上,您需要从Windows保险库中删除git凭据.
您可以检查您正在使用的Git 凭据,并使用您的新帐户进行更改。
正如您提到的问题的最佳答案所说,使用 SSH 方式
$ git remote set-url origin git@github.com:new_user/new_repo.git
Run Code Online (Sandbox Code Playgroud)
(并设置SSH Key)代替HTTPS方式也是一种解决方法。