请求的URL返回错误:403访问github.com时禁止访问

时间:2016-06-23 03:54:13

标签: git github

所以,我在另一台机器上有一个repo设置。我已经提交并推送了文件,他们在github.com上查看得很好。现在,我已经在另一台机器上运行了git init,我试图拉动它。

# git remote set-url origin git@github.com:me/someproj.git
fatal: No such remote 'origin'

# git remote add origin https://github.com/me/someproj.git

# git pull
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/me/someproj.git/info/refs

fatal: HTTP request failed

# git remote -v
origin  https://github.com/me/someproj.git (fetch)
origin  https://github.com/me/someproj.git (push)

# git pull origin
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/me/someproj.git/info/refs

fatal: HTTP request failed

5 个答案:

答案 0 :(得分:8)

您需要检查推送到GitHub的计算机上使用的凭据(用户名/密码),并在新的本地存储库中重新使用这些凭据。

特别检查所用网址的类型:ssh(git@github.com:me/someproj.git)或https(https://github.com/me/someproj.git)。
如果你是using 2FA (Two-Factor Authentication),那么请查看该GitHub帐户和回购。

您可以嵌入right username in your url ::

cd /path/to/new/local/repo
git remote add origin https://me@github.com/me/someproj.git

答案 1 :(得分:1)

尝试从浏览器访问https://github.com/me/someproj.git/info/refs时,您会注意到以下与403状态代码相关联的消息:

  

请升级您的git客户端。 GitHub.com不再支持git了   哑HTTP:   https://github.com/blog/809-git-dumb-http-transport-to-be-turned-off-in-90-days

如果您在1.6.6之前使用git,请尝试更新它或更好地使用SSH协议。

同时使用git config --global user.namegit config --global user.password检查您的设置。

答案 2 :(得分:0)

您可以尝试使用git remote -v命令检查远程repo URL是否正常。 如果不是,你应该尝试

git remote set-url origin repo-url

修复任何拼写错误

答案 3 :(得分:0)

对于那些通过删除凭据或url更改仍无法解决问题的人。

我强烈建议您检查一下您是否有权推送到存储库。为了确保这一点,请在存储库设置的“ 管理访问权限”部分中,让存储库管理员授予您 WRITE 权限。 希望这对您有用。

the manage access section in github add contributor

答案 4 :(得分:0)

如果您在同一台计算机上使用两个帐户,则会引发此错误。

enter image description here

在Windows 10中 控制面板->用户帐户->管理您的凭据。 删除github帐户。