如果没有什么别的问题的话,推荐使用SSH的方式。请参考:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed

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 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

Also set it up with verbose mode. I'm still pretty baffled.

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

These are the versions of git and curl that I have:

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
asked Sep 15 '11 at 22:45
Mike
6,39062660
 
    
Look at the comment, which should be posted as an answer. Made it work with 1.7.1, had the missing User/Password prompt problem, too. Props to stackoverflow.com/a/9575906/805284 ... –  sjas Mar 1 '13 at 14:27
1  
check the user has read/write access to the repository –  Céline Aussourd May 1 '13 at 10:49
6  
In the future, don't paste "Authorization: Basic <stuff>" when showing example http headers. It's easy to base64 decode that and get your password. @mike: if you haven't changed your github password since you posted this question, I would suggest you do so. –  FlipMcF Jul 31 '13 at 22:07
1  
@FlipMcF Thanks man. Was unaware. Password changed. –  Mike Aug 1 '13 at 13:01
1  
@Mike NP. Now I get to shamelessly promote a little blog I wrote on it: goo.gl/bpae94 –  FlipMcF Aug 1 '13 at 17:03

27 Answers

up vote379down voteaccepted

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:

  1. edit .git/config file under your repo directory
  2. find url=entry under section [remote "origin"]
  3. change it from url=https://MichaelDrogalis@github.com/derekerdmann/lunch_call.git tourl=ssh://git@github.com/derekerdmann/lunch_call.git. that is, change all the texts before @ symbol to ssh://git
  4. Save config file and quit. now you could use git push origin master to sync your repo on GitHub
answered Oct 14 '11 at 18:26
Sean
4,2481719
 
31  
This is often encountered when you clone with the git read-only address (which is the default when you aren't logged in) instead of the read+write ssh address. –  Nitrodist Nov 15 '11 at 15:22 
15  
My .git/config was more like url=https://github.com/mynickname/my_repo.git But I also changed it like url=ssh://git@github.com/mynickname/my_repo.git and it did the trick – Guillaume Flandre Dec 29 '11 at 21:16 
6  
You can change a repo url with git remote set-url command. See my answer below. –  ilzoff Jun 4 '12 at 22:33
4  
or simply change it from the command line using git remote set-url <name> git@github.com:<username>/<repo>.git –  Yasky Jul 9 '12 at 5:31
18  
For those looking for a non ssh solution, check a few of the other answers here. Adding your username to the https url seems to work. (change config url so that https://@github.com/... is UNAME@github.com/...) – Cyrus Dec 12 '12 at 17:05

To definitely be able to login using https protocol, you should first set your authentication credential to the git Remote URI:

git remote set-url origin https://yourusername@github.com/user/repo.git

Then you'll be asked for a password when trying to git push.

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.

answered Jul 6 '12 at 19:41
 
4  
SSH blocked at work so I have to use HTTPS. Adding the username fixes my issues. –  David Poole Oct 13 '12 at 15:40
3  
This should be the accepted answer. No reason to manually edit a config file when there's a command line interface to it. –  Steve Bennett Jun 12 '13 at 5:23
1  
Also, for me, this way (username@github...) asked for password and worked, whereas ssh://git@github... failed expecting public key auth. –  Steve Bennett Jun 12 '13 at 5:25
    
works and should be the accepted answer! Especially in environments in which ssh does not work, this is the way to go. Thanks! –  AndreasEK Oct 16 '13 at 14:14
1  
@Achint it's an authentication format. You could set your password toohttps://youruser:password@github.com/user/repo.git despite not secure –  Thiago F MacedoDec 2 '13 at 17:24 

One small addition to Seans answer.

Instead of editing .git/config file manually, you can use git remote set-url command.

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.

answered Jun 4 '12 at 22:29
ilzoff
877811
 
    
I don't know if this is just an old post and git has changed, but as today to fix the problem I had to use git remote set-url origin ssh://git@github.com:derekerdmann/lunch_call.git with a colon between the github.com and the repo name –  KevinL Aug 20 at 19:49

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...

answered Jan 17 '12 at 17:27
BMB
99176
 
    
but why? I didn't have to do that in the past. Did a certificate expire, or something? –  Thufir Jun 11 '12 at 11:42
    
Not sure, I'm not an expert, that's just how I got it to work in my case :) –  BMB Dec 4 '12 at 9:45

Edit .git/config file under your repo directory

Find url= entry under section [remote "origin"]

Change it from url=https://github.com/rootux/ms-Dropdown.git tohttps://USERNAME@github.com/rootux/ms-Dropdown.git

where USERNAME is your github user name

answered Nov 7 '12 at 9:39
Gal Bracha
1,6621231
 

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 git push origin master wouldn't even ask for a password till I added it.

answered Jun 27 '12 at 14:44
nisah
577616
 
    
Yes, this is correct! –  Rafael Reiter Mar 25 '13 at 15:58

Upgrade your git. GitHub has answered this question at https://help.github.com/articles/error-the-requested-url-returned-error-403.

answered Jun 20 '12 at 19:03
gsf
18124
 
    
It's half the answer, for sure. Other half is what we have here. –  Mike Jun 20 '12 at 19:06

Figured it out. I cloned over HTTPS. Setting up my public SSH keys, cloning over SSH, and pushing over SSH fixed it.

answered Sep 16 '11 at 3:29
Mike
6,39062660
 
    
Hmmm... but what when you can't use anything but https, because of a corp firewall, for instance?... According to the github blog, the https access was added to github just for that purpose? –  filofel Nov 21 '11 at 14:59
    
I really don't know. I always clone over SSH now. –  Mike Nov 22 '11 at 1:45
    
Just for posterity (I noticed the timestamp), in regards to filofel's comment: Check out my answer listed above. I have the same restriction you mention, at my school, and found I was supplying the wrong password/passphrase to the terminal prompt. Hope it helps any others with the same issue. –  BMB Feb 25 '12 at 0:10 
answered Dec 6 '12 at 18:37
islam
3412619
 
    
That worked for me too –  svassr Mar 19 '13 at 22:23

A 403 code is "Forbidden". The server saw your request and refused it. Do you have permission to push to that repository?

answered Sep 16 '11 at 0:32
Nick Veys
10.3k1440
 
    
Me and a friend are having the same problem. The repo is mine, and he can't push. How do we fix this? – gibson Nov 11 at 17:07

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?

answered Mar 5 '12 at 23:49
patcon
1,015166
 
    
Yes, https push to github works here (even through proxy with password). I use git 1.7.3. For me, it failed first because I typed the wrong password. –  guettli Apr 26 '12 at 10:37
5  
It works for me with git 1.7.1, but there is one thing you have to pay attention too (and that was what I missed in my first try): Give the user name in the HTTPS-URL, i.e.url=https://username@github.com/username/repo.git –  lwho Jun 16 '12 at 10:04

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 "@".

answered Oct 18 '12 at 1:07
 

Sometimes there is nothing wrong with settings, and there are some problems on github servers.

https://status.github.com - current status of github :)

answered Apr 1 at 23:23
noisy
70821750
 
    
You can also get GitHub status updates from their Twitter status account. –  Cupcake Jul 29 at 16:06

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.

answered Aug 29 '12 at 11:57
 

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.

answered May 7 '13 at 0:01
 

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"
answered Feb 17 at 21:08
Lucas Ou
8401033
 
    
Does not work for me. Config has been set, use github.com.. with no '@' in it –  ses Mar 13 at 2:19

After changing https to http within gitbox app, it worked for me.

answered Mar 10 at 19:13
Alex Stone
8,9821585182
 
    
got 403 while accessing by http. –  ses Mar 13 at 2:13

github push403错误的处理的更多相关文章

  1. 解决github push错误The requested URL returned error: 403 Forbidden while accessing

    来源:http://blog.csdn.net/happyteafriends/article/details/11554043 github push错误: git push error: The  ...

  2. 解决github push错误The requested URL returned error: 403 Forbidden while accessing(转)

    github push错误: git push error: The requested URL returned error: 403 Forbidden while accessing https ...

  3. go can't find import: "github.com/** 错误

    go get 后 go build 错误 can't find import: "github.com/ 原因: 1.gopath 没配好 2.go get 后要先 go install , ...

  4. github常见错误提示之一

    如果输入$ Git remote add origin git@github.com:Jomsou(github帐号名)/gitdemo(项目名).git 提示出错信息:fatal: remote o ...

  5. push本地代码到github发生错误的解决办法

    有一天,我在github上编写好了README.md这个文件,接着发现本地有段代码忘记上传了,于是熟练的输入git add .   git commit -m "modify",以 ...

  6. github常见错误

    如果输入$ Git remote add origin git@github.com:djqiang(github帐号名)/gitdemo(项目名).git 提示出错信息:fatal: remote ...

  7. 搭建 hexo,在执行 hexo deploy 后,出现 error deployer not found:github 的错误

    hexo 更新到3.0之后,deploy的type 的github需要改成git 改了之后执行npm install hexo-deployer-git --save 然后再部署试试 官网说明: ht ...

  8. GITHUB 提交错误 Error: Permission denied (publickey) 解决

    1.  在开发机上生成自己的密钥 ssh-keygen -b 1024 -t rsa -b 指密钥对长度  -t 指加密方式 Enter file in which to save the key ( ...

  9. GitHub常见错误解决办法

    如果輸入$ git remote add origin git@github.com:djqiang(github帳號名)/gitdemo(項目名).git 提示出錯信息:fatal: remote ...

随机推荐

  1. JpGraph使用详解

    微信平台开发的推广支持应用里,为了满足用户渠道推广分析的需要,公众平台提供了生成带参数二维码的接口.使用该接口可以获得多个带不同场景值的二维码,用户扫描后,公众号可以接收到事件推送,借此可以通过统计不 ...

  2. Java课程设计---web版斗地主

    一. 团队课程设计博客链接 二.个人负责模块和任务说明 负责前后端数据传输 JSP界面的设计 根据后台传来的数据进行页面动态更新 负责Servlet设计 三.自己的代码提交记录截图 四.自己负责模块或 ...

  3. 国产FPGA市场分析 该如何破局

    2018年上半年对于中国半导体行业而言是多事之秋,发生了几件让国人深入思考的大事.我作为IC产业的逃兵,最近也在思考很多的问题,包括资本市场.集成电路行业和研究所的一些不成熟的想法. 2008年进入华 ...

  4. HDU 2199 Can you solve this equation?(二分精度)

    HDU 2199 Can you solve this equation?     Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == ...

  5. VMware vSphere Client下增加虚拟机磁盘空间的方法

    随着系统运维时间的增长,磁盘就日益的损耗,如果遇到虚拟机报磁盘空间不足怎么办?还好,我们可以通过磁盘阵列增加磁盘空间,然后扩容到虚拟机中去. 对于linux虚拟机磁盘扩容的方案有两种,一种就是原有的实 ...

  6. [置顶] linux c常用函数 (待完善)

    (1)字符测试函数 isalnum(测试字符是否为英文字母或数字) isalpha(测试字符是否为英文字母) isascii(测试字符是否为ASCII码字符) isblank(测试字符是否为空格字符) ...

  7. TNS-12535: TNS:operation timed out、TNS-00505: Operation timed out

    在查看alert日志的时候发现: 1 *********************************************************************** 2 3 Fatal ...

  8. docker-ubuntu镜像,nginx镜像

    docker 是将程序与机器隔开,使程序不受环境影响. 安装 sudo apt-get install docker.io ## 好用的一些命令 1.停用全部运行中的容器: docker stop $ ...

  9. 安装face_recognition

    Ubuntu安装face_recognition需要先安装dlib 1.安装dlib的依赖 sudo apt-get install build-essential cmake sudo apt-ge ...

  10. go run helper

    # go run helper -a :强制编译相关代码,不论编译代码是否最新 -n :打印编译过程需要用到的命令,但不真正执行他们 -p n :并行编译,n为并行的数量 -v :列出被编译的代码包的 ...