下面是您可能收到的 HTTPS 错误示例:
> error: The requested URL returned error: 401 while accessing
> https://github.com/user/repo.git/info/refs?service=git-receive-pack
> fatal: HTTP request failed
> Error: The requested URL returned error: 403 while accessing
> https://github.com/user/repo.git/info/refs
> fatal: HTTP request failed
> Error: https://github.com/user/repo.git/info/refs not found: did you run git
> update-server-info on the server?
检查 Git 版本
与 GitHub 交互没有最低 Git 版本要求,但我们发现 1.7.10 版是一个方便、稳定的版本,适用于许多平台。 您可随时在 Git 网站上下载最新版本。
确保远程正确
您要提取的仓库必须存在于 GitHub 上,且 URL 区分大小写。
您可以打开命令行并输入 git remote -v 来查找本地仓库的 URL:
$ git remote -v
# View existing remotes
> origin https://github.com/github/reactivecocoa.git (fetch)
> origin https://github.com/github/reactivecocoa.git (push)
$ git remote set-url origin https://github.com/github/ReactiveCocoa.git
# Change the 'origin' remote's URL
$ git remote -v
# Verify new remote URL
> origin https://github.com/github/ReactiveCocoa.git (fetch)
> origin https://github.com/github/ReactiveCocoa.git (push)
也可通过 GitHub Desktop 应用程序更改 URL。
提供访问令牌
To access GitHub, you must authenticate with a personal access token instead of your password. For more information, see "Creating a personal access token."
如果要访问使用 SAML SSO 的组织,您在进行身份验证之前还必须授权个人访问令牌访问组织。 更多信息请参阅“关于使用 SAML 单点登录进行身份验证”和“授权个人访问令牌用于 SAML 单点登录”。
检查您的权限
提示输入用户名和密码时,确保使用可以访问仓库的帐户。
Tip: If you don't want to enter your credentials every time you interact with the remote repository, you can turn on credential caching.
改用 SSH
如果您以前设置了 SSH 密钥,便可使用 SSH 克隆 URL,而不使用 HTTPS。 更多信息请参阅“我应使用哪个远程 URL?”