如果沒有什麼别的問題的話,推薦使用SSH的方式。請參考:http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed

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.
Also set it up with verbose mode. I'm still pretty baffled.
These are the versions of git and curl that I have:
<a href="http://stackoverflow.com/posts/7438313/revisions">edited Apr 1 at 23:31</a>
<a href="http://stackoverflow.com/users/456814/cupcake">Cupcake</a>
29.9k974100
asked Sep 15 '11 at 22:45
<a href="http://stackoverflow.com/users/385897/mike">Mike</a>
6,39062660
1
6
<a href="http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed">show 1 more comment</a>
<a></a>
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:
edit <code>.git/config</code> file under your repo directory
find <code>url=</code>entry under section <code>[remote "origin"]</code>
change it from <code>url=https://[email protected]/derekerdmann/lunch_call.git</code> to<code>url=ssh://[email protected]/derekerdmann/lunch_call.git</code>. that is, change all the texts before <code>@</code> symbol to <code>ssh://git</code>
Save <code>config</code> file and quit. now you could use <code>git push origin master</code> to sync your repo on GitHub
<a href="http://stackoverflow.com/posts/7771927/revisions">edited Jan 8 '13 at 23:25</a>
<a href="http://stackoverflow.com/users/1108560/atomiccharles">AtomicCharles</a>
561312
answered Oct 14 '11 at 18:26
<a href="http://stackoverflow.com/users/562154/sean">Sean</a>
4,2481719
31
15
4
18
<a href="http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed">show 4 more comments</a>
To definitely be able to login using <code>https</code> protocol, you should first set your authentication credential to the git Remote URI:
Then you'll be asked for a password when trying to <code>git push</code>.
In fact, this is on the http authentication format. You could set a password too:
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.
<a href="http://stackoverflow.com/posts/11368701/revisions">edited Jan 28 at 0:32</a>
answered Jul 6 '12 at 19:41
<a href="http://stackoverflow.com/users/667927/thiago-f-macedo">Thiago F Macedo</a>
1,8201711
3
One small addition to Seans answer.
Instead of editing <code>.git/config</code> file manually, you can use <code>git remote set-url</code> command.
In your case it should be:
I find it easier and cleaner, than messing around with dot-files.
<a href="https://help.github.com/articles/changing-a-remote-s-url">help.github.com: Changing a remote's URL</a>
answered Jun 4 '12 at 22:29
<a href="http://stackoverflow.com/users/237920/ilzoff">ilzoff</a>
877811
<a>add a comment</a>
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
<a href="http://stackoverflow.com/users/670768/bmb">BMB</a>
99176
Edit <code>.git/config</code> file under your repo directory
Find <code>url=</code> entry under section <code>[remote "origin"]</code>
Change it from <code>url=https://github.com/rootux/ms-Dropdown.git</code> to<code>https://[email protected]/rootux/ms-Dropdown.git</code>
where <code>USERNAME</code> is your github user name
<a href="http://stackoverflow.com/posts/13266968/revisions">edited Feb 21 at 22:05</a>
<a href="http://stackoverflow.com/users/2065702/zach-saucier">Zach Saucier</a>
11.8k41346
answered Nov 7 '12 at 9:39
<a href="http://stackoverflow.com/users/395804/gal-bracha">Gal Bracha</a>
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 <code>git push origin master</code> wouldn't even ask for a password till I added it.
answered Jun 27 '12 at 14:44
<a href="http://stackoverflow.com/users/195620/nisah">nisah</a>
577616
answered Jun 20 '12 at 19:03
<a href="http://stackoverflow.com/users/589391/gsf">gsf</a>
18124
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
answered Dec 6 '12 at 18:37
<a href="http://stackoverflow.com/users/200489/islam">islam </a>
3412619
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
<a href="http://stackoverflow.com/users/78613/nick-veys">Nick Veys</a>
10.3k1440
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
<a href="http://stackoverflow.com/users/504018/patcon">patcon</a>
1,015166
5
change it from
to
It works!
Do not forget the "git" before the "@".
<a href="http://stackoverflow.com/posts/12945689/revisions">edited Oct 18 '12 at 1:16</a>
<a href="http://stackoverflow.com/users/1301851/juan-sosa">Juan Sosa</a>
2,85111430
answered Oct 18 '12 at 1:07
<a href="http://stackoverflow.com/users/1398290/jimmydong">JimmyDong</a>
585
Sometimes there is nothing wrong with settings, and there are some problems on github servers.
answered Apr 1 at 23:23
<a href="http://stackoverflow.com/users/338581/noisy">noisy</a>
70821750
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
<a href="http://stackoverflow.com/users/673217/richardw11">RichardW11</a>
520212
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
<a href="http://stackoverflow.com/users/491812/gnoll110">gnoll110</a>
916
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.
answered Feb 17 at 21:08
<a href="http://stackoverflow.com/users/1660802/lucas-ou">Lucas Ou</a>
8401033
After changing https to http within gitbox app, it worked for me.
answered Mar 10 at 19:13
<a href="http://stackoverflow.com/users/967484/alex-stone">Alex Stone</a>
8,9821585182
歡迎加群互相學習,共同進步。QQ群:iOS: 58099570 | Android: 572064792 | Nodejs:329118122 做人要厚道,轉載請注明出處!
本文轉自張昺華-sky部落格園部落格,原文連結:http://www.cnblogs.com/sunshine-anycall/p/4155926.html,如需轉載請自行聯系原作者