如果没有什么别的问题的话,推荐使用SSH的方式。请参考:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed
241 119 | I was able to clone a copy of this repo over HTTPS authenticated. I've made some commits and want to push back out to the GitHub server. Using Cygwin on Windows 7 x64. C:\cygwin\home\XPherior\Code\lunch_call>git pushPassword:error: The requested URL returned error: 403 while accessing https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git/info/refsfatal: HTTP request failed Also set it up with verbose mode. I'm still pretty baffled. C:\cygwin\home\XPherior\Code\lunch_call>set GIT_CURL_VERBOSE=1C:\cygwin\home\XPherior\Code\lunch_call>git pushPassword:* 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 Assurance EV CA-1* SSL certificate verify ok.> GET /derekerdmann/lunch_call.git/info/refs?service=git-receive-pack HTTP/1.1User-Agent: git/1.7.4.3282.g844cbHost: github.comAccept: */*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/derekerdmann/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.1Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXUser-Agent: git/1.7.4.3282.g844cbHost: github.comAccept: */*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 Assurance EV CA-1* SSL certificate verify ok.* Server auth using Basic with user 'MichaelDrogalis'> GET /derekerdmann/lunch_call.git/info/refs HTTP/1.1Authorization: Basic xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxUser-Agent: git/1.7.4.3282.g844cbHost: github.comAccept: */*Pragma: no-cache* The requested URL returned error: 403* Expire cleared* Closing connection #0error: The requested URL returned error: 403 while accessing https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git/info/refsfatal: HTTP request failed These are the versions of git and curl that I have: C:\Users\XPherior>git --versiongit version 1.7.4.msysgit.0C:\Users\XPherior>curl --versioncurl 7.21.7 (amd64-pc-win32) libcurl/7.21.7 OpenSSL/0.9.8r zlib/1.2.5Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtspsmtp smtps telnet tftpFeatures: AsynchDNS GSS-Negotiate Largefile NTLM SSL SSPI libz | ||||||||||||||||||||
|
27 Answers
379accepted | I just got the same problem and just figured out what's cause. Github seems only supports ssh way to read&write the repo, although https way also displayed 'Read&Write'. So you need to change your repo config on your PC to ssh way:
| ||||||||||||||||||||
|
160 | To definitely be able to login using git remote set-url origin https://yourusername@github.com/user/repo.git Then you'll be asked for a password when trying to In fact, this is on the http authentication format. You could set a password too: https://youruser:password@github.com/user/repo.git You should be aware that if you do this, your github password will be stored in plaintext in your .git directory, which is obviously undesirable. | ||||||||||||||||||||
|
63 | One small addition to Seans answer. Instead of editing In your case it should be: git remote set-url origin ssh://git@github.com/derekerdmann/lunch_call.git I find it easier and cleaner, than messing around with dot-files. | ||||
|
27 | The other answers that suggest switching to SSH sort of miss the point. HTTPS is supported, but you must log in with you GITHUB password, not your SSH passphrase (which was what was giving me the same exact error). I was having the same problem, but making sure to use my actual GitHub password at the terminal password prompt fixed the solution with no alteration to the config, or resorting to SSH. The reason it is important to note this, is many public institutions (such as my school) will block SSH, but allow HTTPS (which is the only reason I started cloning over HTTPS in the first place). Hope that helps anyone else having the same issue... | ||||||||
|
16 | Edit Find Change it from where | |||
|
12 | I think @deepwaters got the answer correct for older versions. The HTTPS URL needs to have the username. I had git 1.7.0.4 and | ||||
|
7 | Upgrade your git. GitHub has answered this question at . | ||||
|
6 | Figured it out. I cloned over HTTPS. Setting up my public SSH keys, cloning over SSH, and pushing over SSH fixed it. | ||||||||||||
|
4 | Just add you username into url like this : please check: | ||||
|
4 | A 403 code is "Forbidden". The server saw your request and refused it. Do you have permission to push to that repository? | ||||
|
2 | For anyone curious, my mac machine vs lucid vm ran git 1.7.6 vs 1.7.0.4, and the exact same repo was pushable from my mac (newer git) but not the VM Same curl version. Perhaps some older git versions don't support https pushes? | ||||||||
|
2 | change it from url=https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git to url=ssh://git@github.com/derekerdmann/lunch_call.git It works! Do not forget the "git" before the "@". | |||
|
2 | Sometimes there is nothing wrong with settings, and there are some problems on github servers. - current status of github :) | ||||
|
1 | I had this problem right now, and it turned out that my server /etc/resolver.conf file had a bad ip address. Might help others. | ||
|
1 | It could be an accounting issue. The Github account of the upstream (private) repo owner may not be financial. I've seen this where the client's credit card expired. | ||
|
1 | I figured out my own variation of this problem. The issue was not changing the protocol from https to ssl, but instead, setting the Github global username and email! (I was trying to push to a private repository. git config --global user.email "your_github_email_@email.com"git config --global user.name "Your full name" | ||||
|
1 | After changing https to http within gitbox app, it worked for me. | ||||
|