User
User

Reputation: 24741

The requested URL returned error: 403 Forbidden while accessing github.com

So, I have a repo setup, on another machine. I've committed and pushed files and they view fine on github.com. Now, I have ran git init on another machine and I'm trying to pull.

# git remote set-url origin [email protected]:me/someproj.git
fatal: No such remote 'origin'

# git remote add origin https://github.com/me/someproj.git

# git pull
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/me/someproj.git/info/refs

fatal: HTTP request failed

# git remote -v
origin  https://github.com/me/someproj.git (fetch)
origin  https://github.com/me/someproj.git (push)

# git pull origin
error: The requested URL returned error: 403 Forbidden while accessing https://github.com/me/someproj.git/info/refs

fatal: HTTP request failed

Upvotes: 12

Views: 86742

Answers (5)

Ahmad Sharif
Ahmad Sharif

Reputation: 4435

If you use two account in same computer it will throw this error.

enter image description here

In windows 10 Control Panel -> User Accounts -> Manage your credentials. Remove the github account.

Upvotes: 3

marmofayezi
marmofayezi

Reputation: 104

For those whose problem is not solved with deleting the credential or url change.

I strongly recommend to check that you have the permission to push to the repo. To make sure, ask the repo's admin to give you the WRITE permission in the 'Manage Access' section of the repo's settings. Hope this works for you.

the manage access section in github add contributor

Upvotes: 1

dstrants
dstrants

Reputation: 7705

You can try the git remote -v command to check the remote repo URL is ok. If it is not, you should try

git remote set-url origin repo-url

To fix any typos

Upvotes: 2

Shmulik Klein
Shmulik Klein

Reputation: 3914

When trying to access https://github.com/me/someproj.git/info/refs from the browser you'll notice the following message which associated with a 403 status code:

Please upgrade your git client. GitHub.com no longer supports git over dumb-http: https://github.com/blog/809-git-dumb-http-transport-to-be-turned-off-in-90-days

If you are using git prior to 1.6.6, try to update it or better use a SSH protocol.

Also check your setup with git config --global user.name and git config --global user.password.

Upvotes: 2

VonC
VonC

Reputation: 1324977

You need to check what credential (username/password) you are using on the machine where a push to GitHub succeed, and re-use those credential in your new local repo.

Check especially the type of url used: ssh ([email protected]:me/someproj.git) or https (https://github.com/me/someproj.git).
Check also if you were using 2FA (Two-Factor Authentication) or not for that GitHub account and repos.

You can embed the right username in your url::

cd /path/to/new/local/repo
git remote add origin https://[email protected]/me/someproj.git

Upvotes: 12

Related Questions