Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

git - 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
...