git 错误:请求的 URL 返回错误:403 Forbidden while accessing
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19722521/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
error: The requested URL returned error: 403 Forbidden while accessing
提问by Aniket Thakur
I have a git repository. I have a GUI client in Windows and EGit in Eclipse ADT. Generally I edit in Eclipse ADT and use the GUI Client to update the Github repo. First I commit (which creates a buffer) and then when I sync it uploads it to my actual repo.
我有一个 git存储库。我在 Windows 中有一个 GUI 客户端,在 Eclipse ADT 中有一个 EGit。通常我在 Eclipse ADT 中编辑并使用 GUI 客户端更新 Github 存储库。首先我提交(它创建一个缓冲区),然后当我同步它时将它上传到我的实际存储库。
Now I have clone my repo on Linux(CentOS 6.4). Everything is setup. I changed some file. Then I used git add
and git commit -m "message" -a
command and it worked fine. But my actual github repo was not updated. After bit of googling I figured out that we have to explicitly provide git push
command. After which I am getting
现在我已经在 Linux(CentOS 6.4)上克隆了我的仓库。一切都设置好了。我更改了一些文件。然后我使用git add
和git commit -m "message" -a
命令它工作正常。但是我的实际 github 存储库没有更新。经过一番谷歌搜索,我发现我们必须明确提供git push
命令。之后我得到
[aniket@localhost Android]$ git push
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/aniket91/Android.git/info/refs
fatal: HTTP request failed
What is going wrong? There is no firewall or proxy and I have close by iptables service. Has anyone encountered this scenario before? What should be done?
出了什么问题?没有防火墙或代理,我已经关闭了 iptables 服务。有没有人遇到过这种情况?应该做什么?
After following thisanswer (which kind of worked I got following error)
按照这个答案之后(哪种工作我得到了以下错误)
[aniket@localhost Android]$ git push origin master
The authenticity of host 'github.com (192.30.252.130)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.130' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Any suggestions are appreciated.
任何建议表示赞赏。
采纳答案by VonC
The answer you mentionsuggests to change the url from an https one to an ssh one.
您提到的答案建议将 url 从 https 更改为 ssh 。
That would only work if you have a ~/.ssh/id_rsa
and ~/.ssh/id_rsa.pub
, with the latter (public key) published in your GitHub ssh keys.
这仅在您有~/.ssh/id_rsa
and时才有效~/.ssh/id_rsa.pub
,后者(公钥)发布在您的GitHub ssh keys 中。
Check your Egit ssh configuration.
检查您的Egit ssh 配置。
For step by step procedure as of how to generate SSH key and set it in your GitHub setting hereis the link.
有关如何生成 SSH 密钥并将其设置在您的 GitHub 设置中的分步过程,请点击此处的链接。
回答by Bhanu P
So i faced the same problem with git to push the content to repository.
所以我在使用 git 将内容推送到存储库时遇到了同样的问题。
Error info:
错误信息:
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/bhanurhce/rhel6-exapmpleserver.git/info/refs
错误:请求的 URL 返回错误:403 Forbidden while accessing https://github.com/bhanurhce/rhel6-exapmpleserver.git/info/refs
fatal: HTTP request failed
致命:HTTP 请求失败
Work around for me:
为我解决:
This error is majorly due to the LOGIN credentials from your local machine in the git hub. You have to provide the username & password of github
此错误主要是由于 git hub 中本地计算机的 LOGIN 凭据。你必须提供github的用户名和密码
Add username: $ git config --global user.name "bhanurhce"Username should be github's user account.
添加用户名:$ git config --global user.name "bhanurhce"用户名应该是github的用户账号。
Confirm the username: $ git config user.name
确认用户名:$ git config user.name
once you try to push then it will ask for password:
一旦您尝试推送,它就会要求输入密码:
$ git push -u origin master
Password:(provide your github's password.)
$ git push -u origin master
Password:(提供你的github密码。)
issue will be solved.
问题将得到解决。
Even if you still get error for askpass:
即使您仍然收到askpass 错误:
Error info: [root@virtual-master git]# git push -u origin master
错误信息:[root@virtual-master git]# git push -u origin master
(gnome-ssh-askpass:47356): Gtk-WARNING **: cannot open display:
(gnome-ssh-askpass:47356): Gtk-WARNING **: 无法打开显示:
Then just solve it by command: $ unset SSH_ASKPASS
然后直接通过命令解决: $ unset SSH_ASKPASS
All will work fine. Hope it helps..
一切都会好起来的。希望能帮助到你..
Thanks!!
谢谢!!
回答by marcinj
I had the same problem and the cause was that I was using https git access under my linux box. Pull was ok, while push ended with error. The solution was to switch to ssh access, ex:
我遇到了同样的问题,原因是我在我的 linux 机器下使用了 https git 访问。拉没问题,而推则以错误结束。解决方案是切换到 ssh 访问,例如:
So first read remote url:
所以首先读取远程url:
$ git config --get remote.origin.url
https://github.com/yourname/project.git
if you see https then change it to ssh, copy proper url from your github project www, and call:
如果您看到 https 则将其更改为 ssh,从您的 github 项目 www 复制正确的 url,然后调用:
$ git remote set-url origin [email protected]:yourname/project.git
you might still need to put (and maybe also generate) .ssh public key to github. For that look into VonC answer.
您可能仍需要将 .ssh 公钥放入(也可能生成)github。为此,请查看 VonC 的答案。