Git在推送代码时返回错误403 [英] Git returning Error 403 while pushing the code

查看:388
本文介绍了Git在推送代码时返回错误403的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一切正常,直到我创建了一个新的GitHub帐户. 当我尝试使用新帐户将代码首次推送到github服务器时,发生以下错误:

Everything was working fine, until I create a new GitHub account. When I try to push the code for first time to github server with new account, following error is occurring:

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

尝试使用以下方法重置远程URL:

Tried to reset remote url using:

$git remote set-url origin https://username@github.com/user/repo.git ...但不起作用.

$git remote set-url origin https://username@github.com/user/repo.git ... but not working.

此处有一个解决方案,但适用于Mac OS.任何想法如何解决这个问题. 使用git bash version 2.16.1.windows.4.

Got one solution here, but for Mac OS. Any ideas how to resolve this. Using git bash version 2.16.1.windows.4.

谢谢

推荐答案

在同一台计算机上使用两个git帐户时,会发生这种情况. 在Windows 7上,您需要从Windows保险库中删除git凭据.

This happens when two git accounts are being used on same machine. On Windows 7 you need to remove git Credentials from Windows vault.

  • 转到控制面板->用户帐户->管理您的凭据.
  • 在通用凭据"下,删除github凭据的条目.
  • 尝试输入代码,这一次它将提示您再次输入正确的用户名和密码.

  • go to Control Panel -> User Accounts -> Manage your credentials.
  • Under Generic Credentials delete entries for github credentials.
  • Try to push code and this time it will prompt you for correct username and password again.

这篇关于Git在推送代码时返回错误403的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆