Welcome to OGeek Q&A 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 git@github.com: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 Reply

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 (git@github.com: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://me@github.com/me/someproj.git

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...