22

I have created a repository on github named pygame. Created a clone and added files and commited.but when I attempt to push I receive the following error:

git push -u origin master

error: The requested URL returned error: 403 while accessing https://github.com/amalapk/pygame/info/refs

fatal: HTTP request failed

I can ssh to git@github.com and receive the notice that I logged in successfully, but can't push to my repository.

agf
  • 171,228
  • 44
  • 289
  • 238
amala
  • 221
  • 1
  • 2
  • 3
  • 1
    See this question. http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed – hahakubile Jun 08 '12 at 12:38
  • http://stackoverflow.com/questions/7438313/pushing-to-git-returning-error-code-403-fatal-http-request-failed – shweta May 07 '13 at 06:51

7 Answers7

27

I recently experienced this problem when setting up a new clone of my github project.

You need to include your username in the URL to your project, in the form

https://user@github.com/project/...

For example, the URL provided for my test github is this:

https://github.com/jdblair/test.git

If I add my username to it, like this, then I'm able to push and pull from github with no problem:

https://jdblair@github.com/jdblair/test.git

It is easiest to use the URL that contains the username starting from when you clone a project.

You can change the URL for an existing project like this:

git remote set-url origin https://user@github.com/project/foo/bar.git

You can use the ssh authentication instead if you want, but that's a separate setup process.

hadsed
  • 327
  • 2
  • 4
  • 11
jdb
  • 549
  • 5
  • 6
  • This solved the issue for me (I have git 1.7.1 and can't easily upgrade since it's on a server not managed by me) – Davide Apr 29 '13 at 22:54
12

Github now is asking us to use git 1.7.10 or later:

https://help.github.com/articles/error-the-requested-url-returned-error-403

José Ricardo
  • 1,479
  • 1
  • 14
  • 28
11

The GitHub Remote page mentions the read/write addresses for a repo:

Make sure your clone address is like:

https://github.com/username/yourRepo.git

And that you have defined:

git config --global user.name "Firstname Lastname"
git config --global user.email "your_email@youremail.com"

Should you use a git address (without ssh), you would also need:

git config --global github.user username
git config --global github.token 0123456789yourf0123456789token # no longer needed

(with your token coming from “Account Settings” > Click “Account Admin.”)

Update 2013: you still can generate a token (see "Creating an access token for command-line use"), but you would use it as a password for https url.

Actually, if you activate the 2FA (two-factor authentication) mechanism on GitHub, you will need a token for your https url (because your regular password would trigger the second-step verification).
See "Configure Git clients, like GitHub for Windows, to not ask for authentication"

See more at "Which remote URL should I use?".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
6

It's all in the remote.

Change your current remote from https://github.com/amalapk/pygame.git to git@github.com:amalapk/pygame.git and enjoy.

To do this... (assuming your current remote is called origin)

git remote set-url origin git@github.com:amalapk/pygame.git
Igbanam
  • 5,904
  • 5
  • 44
  • 68
  • The `https` protocol is read-only. But the `git` protocol is overplayed on SSH which is readable and writable ...I think – Igbanam Sep 03 '12 at 08:23
1

In my case getting rid of such error message was resolved this way: Person was simply added to github repository as a colaborator. Thats it - error vanished magically.

pbaranski
  • 22,778
  • 19
  • 100
  • 117
-1

Committing to github from server this is what worked for me in the terminal or git bash

To create a remote to github.com try:

git remote add origin https://put your username here@github.com/put your git username here/put your repository name here

To change the remote just do:

git remote set-url origin https://put your username here@github.com/put your git username here/the name of your repository here
-4

Please follow the instructions on http://help.github.com/create-a-repo/

You have cloned your repository with the public read only url.

RTFM

Thomas Berger
  • 1,860
  • 13
  • 26
  • 2
    The URL provided on the "next steps" page does indeed look pretty similar to the URL the OP has provided. My guess is that they have indeed fallen prey to the problem reported in Ze's comment below: github is recommending https:// URLs, but they throw a 403 on older versions of git. – J-P Jun 19 '12 at 14:48