HTTPS cloning errors 用 HTTPS 克隆常见的错误

几个常见的错误关于使用 HTTPS 和 Git。一般出错的原因是你的 Git 版本太旧或者没有访问库的权限。

下面是一些错误示例:

  1. # error: The requested URL returned error: 401 while accessing
  2. # https://github.com/user/repo.git/info/refs?service=git-receive-pack
  3. # fatal: HTTP request failed
  4. # Error: The requested URL returned error: 403 while accessing
  5. # https://github.com/user/repo.git/info/refs
  6. # fatal: HTTP request failed
  7. # Error: https://github.com/user/repo.git/info/refs not found: did you run git
  8. # update-server-info on the server?

Check your Git version 检查 Git 版本

使用 Github 对 Git 版本没有限制,但我们发现在众多平台中 version 1.7.10 是比较稳定的版本。你最好下载最新的版本。

Ensure the remote is correct 确认远程是正确的

你要获取的库必须是存在的,并且 URL 大小写敏感。

查看本地库的 URL ,输入 git remote -v:

  1. $ git remote -v
  2. # View existing remotes
  3. # origin https://github.com/github/reactivecocoa.git (fetch)
  4. # origin https://github.com/github/reactivecocoa.git (push)
  5. $git remote set-url origin https://github.com/github/ReactiveCocoa.git
  6. # Change the 'origin' remote's URL
  7. $git remote -v
  8. # Verify new remote URL
  9. # origin https://github.com/github/ReactiveCocoa.git (fetch)
  10. # origin https://github.com/github/ReactiveCocoa.git (push)

另外,你可以在 Mac 或者 Windows 应用程序中变换 URL

Provide access token if 2FA enabled 提供访问令牌如果 2FA 启动的话

如果启动 2FA (two-factor authentication 双因素认证),必须提供个人访问令牌来替换输入个人密码。

Checking your permissions 检查权限

当输入用户名密码时,请确认这个账户是可以有权限访问库的。

提示:如果在与库交互时,不想每次都输密码,可以保存你的 Github 密码

如果之前已经设置了 SSH 密钥,你可以用 SSH 来代替 HTTPS 克隆 URL。更多信息,查看该文