推送到 Git 返回错误代码 403 致命
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27996017/
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
Pushing to Git returning Error Code 403 fatal
提问by technuma
I want to push README.md to Github.
Using Ubuntu 14.04LTS
So, I commit in the following steps.
我想将 README.md 推送到 Github。
使用 Ubuntu 14.04LTS
因此,我按以下步骤提交。
echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/user/repo.git
git push -u origin master
But, below error occurred.
但是,发生了以下错误。
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/user/repo.git/info/refs
fatal: HTTP request failed
I know solve this error this way
我知道这样解决这个错误
git remote set-url origin https://[email protected]/user/repo.git
In this way , I must enter password.
这样,我必须输入密码。
$ git push origin master
Password:
But I hate to enter password.
但我讨厌输入密码。
I have checked this, but I don't solved.
Pushing to Git returning Error Code 403 fatal: HTTP request failed
我已经检查过这个,但我没有解决。
推送到 Git 返回错误代码 403 致命:HTTP 请求失败
Please tell me how to push without password.
请告诉我如何在没有密码的情况下推送。
采纳答案by Fernando
You have to either use https and enter your password or use ssh (and associate your public ssh key to your github account)
您必须使用 https 并输入密码或使用 ssh(并将您的公共 ssh 密钥关联到您的 github 帐户)
回答by dilei
This may solve your problem:
这可能会解决您的问题:
git remote set-url origin https://username:[email protected]/user/repo.git
回答by Joey Dorrani
I tried my best and looked for the causes/solution of the error:
我尽了最大努力寻找错误的原因/解决方案:
Error: The requested URL returned error: 403 while accessing
https://github.com/Joey-project/repo.git/info/refs
fatal: HTTP request failed
I believe one of the main reasons of this happening is because of bad login credentials from your local machine to the server.
我相信发生这种情况的主要原因之一是因为从本地计算机到服务器的登录凭据错误。
If I remember correctly, one has to
如果我没记错的话,必须
(1) Make sure you have a stable git version
(1) 确保你有一个稳定的 git 版本
(2) Ensure the remote is correct
(2) 确保遥控器正确
(3) Provide access token if 2FA is enabled
(3) 如果启用了 2FA,则提供访问令牌
(4) Checking your permissions(username/password)
(4) 检查您的权限(用户名/密码)
(5) Use ssh instead of https
(5) 使用ssh代替https
Pushing to Git returning Error Code 403 fatal: HTTP request failedmight come in handy, which has a lot of extra information regarding your problem.
推送到 Git 返回错误代码 403 致命:HTTP 请求失败可能会派上用场,其中包含许多关于您的问题的额外信息。
Goodluck! I hope it helps you
祝你好运!我希望它能帮助你
回答by Cartesian Theater
If your problem is the result of a changing a repo (resulting in a username, password mismatch), try this at the command line:
如果您的问题是更改存储库的结果(导致用户名、密码不匹配),请在命令行中尝试:
git credential-osxkeychain erase
host=github.com
protocol=https
[Press Return]
it will prompt you for your username and password.
它会提示您输入用户名和密码。
See https://help.github.com/articles/updating-credentials-from-the-osx-keychain/
请参阅https://help.github.com/articles/updating-credentials-from-the-osx-keychain/
回答by Prof
If you're using multiple github accounts then that could also be the cause of the problem. Git saves the username and password you use first in your OS's credential vault. Any subsequent requests will be using those details regardless of what your IDE tells you.
如果您使用多个 github 帐户,那么这也可能是问题的原因。Git 将您首先使用的用户名和密码保存在操作系统的凭证保险库中。无论您的 IDE 告诉您什么,任何后续请求都将使用这些详细信息。
回答by Bruce Seymour
If you're working with a cloneor fork, double-check that the repository URL you're trying to push to is your fork'sURL instead of the original owner's repository URL.
如果您正在使用clone或fork,请仔细检查您尝试推送到的存储库 URL 是否是您的fork 的URL,而不是原始所有者的存储库 URL。
git remote -v
回答by ggonzal
Just update your git client and you should not get this issue anymore
只需更新您的 git 客户端,您就不会再遇到此问题