我能够通过HTTPS身份验证克隆此repo的副本.我做了一些提交,想要推回到GitHub服务器.在Windows 7 x64上使用Cygwin.
C:\cygwin\home\XPherior\Code\lunch_call>git push
Password:
error: The requested URL returned error: 403 while accessing https://MichaelDrog
alis@github.com/derekerdmann/lunch_call.git/info/refs
fatal: HTTP request failed
Run Code Online (Sandbox Code Playgroud)
同时使用详细模式进行设置.我还是很困惑.
C:\cygwin\home\XPherior\Code\lunch_call>set GIT_CURL_VERBOSE=1
C:\cygwin\home\XPherior\Code\lunch_call>git push
Password:
* Couldn't find host github.com in the _netrc file; using defaults
* About to connect() to github.com port 443 (#0)
* Trying 207.97.227.239... * 0x23cb740 is at send pipe head!
* Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt
CApath: none
* SSL connection using AES256-SHA
* Server certificate:
* subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.
3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L
=San Francisco; O=GitHub, Inc.; CN=github.com
* start date: 2011-05-27 00:00:00 GMT
* expire date: 2013-07-29 12:00:00 GMT
* subjectAltName: github.com matched
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass
urance EV CA-1
* SSL certificate verify ok.
> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache
< HTTP/1.1 401 Authorization Required
< Server: nginx/1.0.4
< Date: Thu, 15 Sep 2011 22:44:41 GMT
< Content-Type: text/plain
< Connection: keep-alive
< Content-Length: 55
< WWW-Authenticate: Basic realm="GitHub"
<
* Ignoring the response-body
* Expire cleared
* Connection #0 to host github.com left intact
* Issue another request to this URL: 'https://MichaelDrogalis@github.com/dereker
dmann/lunch_call.git/info/refs?service=git-receive-pack'
* Couldn't find host github.com in the _netrc file; using defaults
* Re-using existing connection! (#0) with host github.com
* Connected to github.com (207.97.227.239) port 443 (#0)
* 0x23cb740 is at send pipe head!
* Server auth using Basic with user 'MichaelDrogalis'
> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1
Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache
< HTTP/1.1 401 Authorization Required
< Server: nginx/1.0.4
< Date: Thu, 15 Sep 2011 22:44:41 GMT
< Content-Type: text/plain
< Connection: keep-alive
< Content-Length: 55
* Authentication problem. Ignoring this.
< WWW-Authenticate: Basic realm="GitHub"
* The requested URL returned error: 401
* Closing connection #0
* Couldn't find host github.com in the _netrc file; using defaults
* About to connect() to github.com port 443 (#0)
* Trying 207.97.227.239... * 0x23cb740 is at send pipe head!
* Connected to github.com (207.97.227.239) port 443 (#0)
* successfully set certificate verify locations:
* CAfile: C:\Program Files (x86)\Git/bin/curl-ca-bundle.crt
CApath: none
* SSL re-using session ID
* SSL connection using AES256-SHA
* old SSL session ID is stale, removing
* Server certificate:
* subject: 2.5.4.15=Private Organization; 1.3.6.1.4.1.311.60.2.1.3=US; 1.
3.6.1.4.1.311.60.2.1.2=California; serialNumber=C3268102; C=US; ST=California; L
=San Francisco; O=GitHub, Inc.; CN=github.com
* start date: 2011-05-27 00:00:00 GMT
* expire date: 2013-07-29 12:00:00 GMT
* subjectAltName: github.com matched
* issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=DigiCert High Ass
urance EV CA-1
* SSL certificate verify ok.
* Server auth using Basic with user 'MichaelDrogalis'
> GET /derekerdmann/lunch_call.git/info/refs HTTP/1.1
Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
User-Agent: git/1.7.4.3282.g844cb
Host: github.com
Accept: */*
Pragma: no-cache
* The requested URL returned error: 403
* Expire cleared
* Closing connection #0
error: The requested URL returned error: 403 while accessing https://MichaelDrog
alis@github.com/derekerdmann/lunch_call.git/info/refs
fatal: HTTP request failed
Run Code Online (Sandbox Code Playgroud)
这些是我拥有的git和curl的版本:
C:\Users\XPherior>git --version
git version 1.7.4.msysgit.0
C:\Users\XPherior>curl --version
curl 7.21.7 (amd64-pc-win32) libcurl/7.21.7 OpenSSL/0.9.8r zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtsp
smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate Largefile NTLM SSL SSPI libz
Run Code Online (Sandbox Code Playgroud)
Xia*_*iao 817
我刚刚遇到同样的问题,只是弄明白是什么原因.
Github似乎只支持ssh方式来读取和写入repo,虽然https方式也显示"Read&Write".
因此,您需要将PC上的repo配置更改为ssh方式:
.git/configrepo目录下的文件url=条目下的条目[remote "origin"]url=https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git改为 url=ssh://git@github.com/derekerdmann/lunch_call.git.也就是说,将@符号前的所有文本更改为ssh://gitconfig文件并退出.现在你可以用来git push origin master在GitHub上同步你的回购Thi*_*edo 413
要确保能够使用https协议登录,您应该首先将您的身份验证凭据设置为git Remote URI:
git remote set-url origin https://yourusername@github.com/user/repo.git
Run Code Online (Sandbox Code Playgroud)
然后在尝试时会要求您输入密码git push.
实际上,这是http身份验证格式.您也可以设置密码:
https://youruser:password@github.com/user/repo.git
Run Code Online (Sandbox Code Playgroud)
您应该知道,如果您这样做,您的github密码将以纯文本形式存储在.git目录中,这显然是不可取的.
fet*_*tsh 110
肖恩答案的一小部分补充.
.git/config您可以使用git remote set-url命令而不是手动编辑文件.
在你的情况下,它应该是:
git remote set-url origin ssh://git@github.com/derekerdmann/lunch_call.git
Run Code Online (Sandbox Code Playgroud)
我发现它比使用点文件更容易,更干净.
Gal*_*cha 53
编辑.git/configrepo目录下的文件
url=在部分下查找条目[remote "origin"]
从更改url=https://github.com/rootux/ms-Dropdown.git到
https://USERNAME@github.com/rootux/ms-Dropdown.git
USERNAME你的github用户名在哪里
BMB*_*BMB 43
其他建议切换到SSH的答案忽略了这一点.支持HTTPS,但您必须使用GITHUB密码登录,而不是SSH密码(这就是给出了同样错误的错误).
我遇到了同样的问题,但确保在终端密码提示下使用我的实际GitHub密码修复了解决方案,没有对配置进行任何更改,也没有使用SSH.
重要的是要注意这一点,许多公共机构(例如我的学校)将阻止SSH,但允许HTTPS(这是我首先开始通过HTTPS克隆的唯一原因).
希望能帮助其他人解决同样的问题......
zee*_*wan 25
Mac OS X上的错误和分辨率相同.
一切正常,直到我在GitHub上创建了一个新帐户并尝试推送
$ git push -u origin master
Run Code Online (Sandbox Code Playgroud)
得到了错误:
remote:对OLDUSER拒绝的NEWUSER/NEWREPO.git的许可.致命:无法访问' https://github.com/NEWUSER/NEWREPO.git/ ':请求的网址返回错误:403
它应该通过为全局或当前repo设置user.name来修复
$ git config –-global user.name NEWUSER
$ git config user.name NEWUSER
Run Code Online (Sandbox Code Playgroud)
但事实并非如此.
我通过从密码链接部分下的Keychain Access应用程序中删除与GitHub相关联的OLDUSER来解决此问题.然后push命令成功.
$ git push -u origin master
Run Code Online (Sandbox Code Playgroud)
nev*_*ves 20
这里有很多答案,但这就是解决我的问题的方法。
自 2020 年 7 月起,如果您使用 HTTPS,则必须使用Token 身份验证来访问 GitHub 。
因此,您必须在个人资料设置页面中生成访问令牌并将其用作密码。选中写入存储库所需的框。
现在使用以下命令将您的用户名添加到存储库:
git remote set-url origin https://yourusername@github.com/user/repo.git
Run Code Online (Sandbox Code Playgroud)
当您尝试推送时,它会要求您输入密码。输入您新生成的令牌。
如果您在推送时仍然遇到问题,请使用 Web 界面将其分叉为个人存储库,以隔离任何权限问题。您将能够专注于解决身份验证问题。
nis*_*sah 17
我认为@dewwaters对旧版本的答案是正确的.HTTPS URL需要具有用户名.我有git 1.7.0.4,git push origin master甚至在我添加之前都不会要求输入密码.
小智 16
这对我有用 - :
git remote set-url origin https://username@github.com/user/repo.git
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你
And*_*ans 14
如果您使用的是Windows,有时可能会发生这种情况,因为Windows会将外部存储库(在我们的例子中为github)的凭据存储在自己的存储中.保存在那里的凭证可能与您现在需要的凭据不同.
因此,要避免此问题,只需在此存储中找到github并删除已保存的凭据.在此之后,推送git将请求您的凭据,并允许您推送.
gsf*_*gsf 13
升级你的git.GitHub已在https://help.github.com/articles/error-the-requested-url-returned-error-403上回答了这个问题.
x0v*_*x0v 10
这样做是为了临时修复
git push -u https://username:password@github.com/username/repo_name.git master
我实际上有一个非常简单的解决方案.我所做的只是在克隆存储库后以不同方式编辑git配置文件.您需要在默认配置文件中编辑远程源URL .它应该如下所示
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://*username*@github.com/*username*/*repository*.git
[branch "master"]
remote = origin
merge = refs/heads/master
Run Code Online (Sandbox Code Playgroud)
下面是解决方案
对于 Windows,您可以在此处找到密钥:
控制面板 > 用户帐户 > 凭据管理器 > Windows 凭据 > 通用凭据
接下来,删除 Github 密钥。
在苹果机上
1-在 Finder 中,搜索“钥匙串访问”应用程序。
2在“钥匙串访问”中,搜索 github.com。
3-找到 github.com 的“互联网密码”条目。
4-相应地编辑或删除条目。
对于那些在使用ssh(根据Xiao)或http url时权限被拒绝403错误的人,请尝试这些命令
>git config --global --unset-all credential.helper
>git config --unset-all credential.helper
Run Code Online (Sandbox Code Playgroud)
有管理员权限
>git config --system --unset-all credential.helper
Run Code Online (Sandbox Code Playgroud)
以上答案都不适用于我的enterpriseGitHub 帐户。按照以下步骤通过 ssh 密钥生成方式进行推送。
通过访问您的 git 帐户创建一个 repo。
生成 ssh 密钥:
ssh-keygen -t rsa -C "your_email@example.com"
Run Code Online (Sandbox Code Playgroud)
将文件 ~/.ssh/id_rsa.pub 的内容复制到 GitHub 帐户设置中的 SSH 密钥。测试 SSH 密钥:
ssh -T git@github.com
clone the repo:
git clone git://github.com/username/your-repository
Run Code Online (Sandbox Code Playgroud)
现在 cd 到您的 git clone 文件夹并执行以下操作:
git remote set-url origin git@github.com:username/your-repository.git
Run Code Online (Sandbox Code Playgroud)
现在尝试编辑一个文件(尝试 README),然后执行:
git add -A
git commit -am "my update msg"
git push -u origin master
Run Code Online (Sandbox Code Playgroud)
更新:新的 git 版本似乎建议在创建新 repo 时不要有任何文件。因此制作一个空白回购。
改变它
url=https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git
Run Code Online (Sandbox Code Playgroud)
到
url=ssh://git@github.com/derekerdmann/lunch_call.git
Run Code Online (Sandbox Code Playgroud)
有用!
不要忘记“@”之前的“git”。
我遇到了同样的错误,原因很愚蠢-我没有权限提交到选定的存储库。我不知道我必须
如https://help.github.com/categories/63/articles中所述
| 归档时间: |
|
| 查看次数: |
754708 次 |
| 最近记录: |